Infra, Apps & APIs Flashcards
Infra, Networking, Security, Apps & APIs
What are the four overarching managed service options on GCP?
IaaS - Compute Engine
PaaS - App Engine
CaaS - Cloud Run
FaaS - Cloud Functions
What are the five fundamental attributes of Cloud Services?
1) On-demand Self-Service - No human intervention needed to access resources
2) Resource Pooling - Provider shares resources to customers
3) Rapid Elasticity
4) Measured Service - Pay for what we consume
5) Internet-Enabled - Access from Anywhere
What are the two primary design principles of cloud native architecting?
1) Scalability:
- Ability to handle varying demands
- Reduce cost of under-utilised resources
- Scale up and down without compromising performance
2) Resilience:
- Functions despite failures of individual components
What are the three migration methodologies for Google Cloud, and what are their pros and cons?
1) Lift and Shift
Pro: No need to rebuild applications or learn cloud skills.
Cons: Ignores cloud-native benefits, applications run without scaling and resilience benefits of cloud-native technologies.
2) Improve and Move
Pro: Introduces automation of scaling and reslience.
Cons: New skills and code management.
3) Rip and Replace
Pro: Remove technical debt
Cons: Requires highest level of time and skill investment.
What are the 4 key design implementation choices to achieve a microservice architecture?
1) Loosely coupled services.
2) Asynchronous operations.
3) Stateless components.
4) Caching.
What is the strangler pattern?
A methodology of incrementally replacing components of legacy applications with new services.
Named after the strangler tree.
What are the four types of technical testing?
1) Unit Testing - Tests individual components of the application.
2) Integration Testing - Tests components grouped together.
3) Performance Testing - Tests the responsiveness of individual components.
4) Load / Endurance Testing - Tests the entire system placed under heavy load.
What is Unit Testing and what are its pros and cons?
Tests individual components of the application.
Pro: Easy to spot errors and automate.
Con: Does not test external dependencies.
What is Integration Testing and what are its pros and cons?
Tests components of an application when they are grouped together and reliant on one another.
Pro: Tests external dependencies and can be automated through mocking.
Cons: Can be difficult to understand the root of errors due to the black-box nature of integration.
What is the recommended production-grade method for running Cloud Build?
Declaratively, by creating a cloudbuild.yaml in your SCR.
What are the 3 types of roles you give to a GCP account within a project and what do they provide?
Primitive Roles - Applys at Project Level: Owner, Editor, Viewer and Billing Administrator.
Predefined Roles - Applys at GCP service level: Such as write access to Cloud Storage, but only view access to Compute Engine.
Custom Roles - Create your own roles such as “instanceOperator” where you can specify and manage the permissions. They can only be specified at the project level, not folder or org.
Explain what blue / green deployment strategy is.
Blue-green deployment is a deployment strategy that utilizes two identical environments, a “blue” (aka staging) and a “green” (aka production) environment with different versions of an application or service. Quality assurance and user acceptance testing are typically done within the blue environment that hosts new versions or changes. User traffic is shifted from the green environment to the blue environment once new changes have been tested and accepted within the blue environment.
What are the pros and cons of a blue / green deployment strategy?
Benefit - Rollback is straight forward, traffic can simply be routed back to the Green environment if the Blue environment sees any issues.
Drawbacks -
1) Cost of running two production-grade environments.
2) Depending on the implementation, shifting all user traffic at once can present risks.
3) In-flight user transactions may be lost when the shift in traffic is made.
Explain what canary deployment is.
A canary deployment is a deployment strategy that releases an application or service incrementally to a subset of users. All infrastructure in a target environment is updated in small phases (e.g: 2%, 25%, 75%, 100%). A canary release is the lowest risk-prone, compared to all other deployment strategies, because of this control.
What is the primary benefit and drawback of canary deployment strategies?
Pro: It’s cheaper than a blue-green deployment because it does not require two production environments.
Con:
- Some tests will need to be conducted in production.
- Often need to establish a trusted tester user base to roll out new features to.
Which fully managed platform uses a container as its sole deployment artifact?
Cloud Run
What are some good uses cases for a message bus like Cloud Pub/Sub?
Distributing messages between downstream microservices.
You wish to direct a small percentage of production traffic to a new version of your application, so that your changes can be tested with live users. What is the name of this deployment pattern?
Canary Deployment
How should application source code be stored for cloud-native software development?
The full codebase, including configuration and deployment files, should be stored in a collaborative source code repository, such as git.
What type of testing tests external dependencies and multiple components and is sometimes referred to as a type of “black box” testing?
Integration testing
You wish to maintain two entirely separate production environments, so that you can work on each one in isolation and then switch all production traffic between them when you are ready to release updates. What is the name of this deployment pattern?
Blue/Green Deployments
What is the MOST efficient way to grant access to an object in cloud storage to an external user with no Google account?
Create a signed URL to grant temporary access to the object.
Signed URLs are a convenient way to embed the necessary authentication information into the URL itself, and to grant time-restricted access to specific objects in file storage.
How can you prevent accidental deletion of objects in cloud storage for a minimum period of time?
Apply a retention policy to the bucket to prevent the deletion of objects until they have reached a minimum age.
Your application expects a MySQL database connection to exist on localhost (i.e., running on the same server), but you would rather use Cloud SQL. How can you facilitate this?
Use the Cloud SQL proxy.
What is the equivilent of a deployment within Kubernetes for Compute Engine?
Managed Instance Groups allow you to spread compute across multiple zones within a region,auto-scaling and auto-healing and from an instance template.
What is the recommended way to install the Cloud Logging agent on a Compute Engine instance running Debian or Ubuntu Linux?
Add the logging agent repo and install using the system package manager.
What are the two methods for running a startup script on a new Compute Engine instance?
1) Define the startup script metadata when the instance is created containing the script itself.
2) Upload a startup script to Cloud Storage, and add its URI as metadata with the key: startup-script-url.
What IAM role is granted to the Compute Engine default service account?
Project Editor
You are running a managed instance group of application servers that you need to make available to other applications in Compute Engine. The application servers should only be accessed internally via private IPs from other Compute Engine services.
What two methods of service discovery could you use for this?
1) Create an internal load balancer with the managed instance group as a backend. Configure an internal DNS name in Cloud DNS for the frontend of the load balancer.
2) Nominate a primary application server and store its private IP in project metadata. Have other services query the metadata server to retrieve the primary application server IP.
You have created a compute engine instance that will connect to a Cloud SQL instance. Following best practice, you are using a custom service account that only grants the Cloud SQL Client permission. You are also using a startup script stored in Cloud Storage to configure your instance. However, when your instance starts, the script does not seem to run. What could be the problem and how might you fix it?
The service account does not have permission to access the startup script in Cloud Storage. Add the Storage Object Viewer role to the service account and reset the instance.
You want to manage a group of stateless web server instances on Compute Engine in a way that would be resilient to the loss of a single GCP zone. What is the best way to achieve this?
Create a regional managed instance group.
Your application requires a VM with 10 vCPUs and 64GB of memory, but this isn’t a predefined option for a machine type in Compute Engine. What do you do?
Create a custom machine type using the GCP console that matches the exact requirements.
Why would you use Cloud Run over Cloud Functions?
1) If you require a runtime-environment not provided by Cloud Functions.
2) If you want to include a persistent file system
3) You can spin up multiple requests per instance with Cloud Run whereas Cloud Functions are one request per instance.
You have a workload running in a deployment on GKE, with a replica set of 4 Pods. Your dev team has provided you with an updated container image and asked you to deploy the update. You want to do this in a way that causes minimal service interruption, but you also want to control the overall amount of resources being consumed, so you don’t need to add nodes to the cluster. What is the best way to update the deployment?
Ensure deployment is using a rolling update. Kubernetes’ default rolling update strategy means that the rollout will pause if more than 25% of new Pods are not healthy, but it will also limit the increased number of Pods in use during the rollout (the surge), to 25%. You can amend this in the deployment.yaml if necessary.
Which of the following is the correct explanation of why a Pod would be in a Succeeded or Completed state?
1) All of the containers in a Pod are running and ready to serve.
2) All of the necessary container images have been downloaded and the Pod is getting ready to start.
3) All of the containers in a Pod have terminated in success and will not be restarted.
4) A Pod has been successfully deleted.
3) All of the containers in a Pod have terminated in success and will not be restarted.
What is the cause of a CrashLoopBackOff error in GKE?
A container has failed to start successfully and continued to fail on repeated attempts.
Your application in GKE needs access to a MySQL database, and your organization has a technical requirement to use managed databases wherever possible. What is the best solution here?
Use Cloud SQL for the database, and use a sidecar container to run the Cloud SQL proxy inside your application’s Pod.
You have a small piece of code that takes an image and resamples it to a thumbnail version. You want to run this code in your GCP project every time a user uploads a photo with your application, which stores user photos in a Cloud Storage bucket. How could you implement this with managed services in a way that does not interfere with the running of the main application?
Deploy the resampling code as a small API program to Cloud Functions. Configure the function to be triggered whenever a new image is uploaded to the storage bucket.
Which open standard specification does Cloud Endpoints and API Gateway require APIs to be defined with?
OpenAPI 2.0
What are some best practices for Google Cloud Functions? (Select 3)
a) Use multiple dependencies for your chosen programming language to avoid the risk of missing libraries.
b) Don’t start background processes.
c) Use only the dependences that are specifically required by the function.
d) Don’t delete temporary files as part of the logic of the function. This is a computing overhead, and the platform automatically clears temporary files.
e) Spawn all processing in the background.
f) Always delete temporary files as part of the logic of the function.
b) Don’t start background processes.
c) Use only the dependences that are specifically required by the function.
f) Always delete temporary files as part of the logic of the function.
What is the default retention period for user logs stored in the default logs bucket?
30 days, and retention can be configured from 1 day to 10 years.
You are developing a backend for a mobile game. The game includes a market place where players can trade items with each other. The details of each trade are written to application logs. You would like to monitor the average price of some items in the game and also create an alert when you suspect an item has been sold for an artificially inflated price. How can you use Operations Suite to help you achieve this in a quick and easy way?
Configure logs-based metrics to track trade prices in Cloud Monitoring. Create an an alerting policy to notify you when a trade price is above a certain threshold.
You have several GCP projects containing resources that you would like to monitor with a single dashboard. What is the recommended way to achieve this?
Configure a separate project as a “host” project for a Cloud Monitoring workspace and use it to manage all the other projects.
You would like to use BigQuery to analyse logs that are collected by Cloud Logging. What is the easiest way to enable this?
Configure BigQuery as a custom sink for logs.
What is the default retention period for audit security logs on GCP?
400 days, and it cannot be changed.
You have deployed an app to App Engine, which seems to be mostly working. Occasionally the application returns an HTTP 500 Internal Server error. It generates lots of logs per request, so you are having difficulty tracking down the problem. Which Operations Suite tool could you most easily use to help you?
Cloud Error Reporting
You have deployed an internal tool to App Engine, and you wish to grant access to other members of your team. You all work remotely, and there is no VPN configuration for your organization. However, everyone has a Google Workspace identity. What is the easiest way to handle authentication for your app?
Use Cloud Identity Aware Proxy and grant the IAP-secured Web App User role to users who should be permitted to access the app.
Which managed GCP service crawls an App Engine, Compute Engine, or GKE application URL to identify security vulnerabilities?
Web Security Scanner
You need to store a series of API keys inside your GCP project, ideally using a managed service. Which is the best option?
Cloud Secret Manager
Your organization works in a regulated industry where you must be able to guarantee the safety and location of data. You are storing sensitive information in Cloud Storage. Which options will help you ensure that data remains in a specific region and is not moved? (Select 2)
A) Multi-region storage buckets
B) Firewall rules
C) Regional storage buckets
D) VPC Service Perimeter
C) Regional storage buckets - Using the regional storage class will allow you to choose a region for data to be stored.
D) VPC Service Perimeter - A VPC service perimeter can guarantee that data will not leave a defined boundary inside a project.
Your organization has two separate product teams that develop their own services in isolation. Each team requires a way to develop their application and deploy it to separate development, staging, and production environments. What is the best way to set this up in the GCP hierarchy?
Use a single GCP organization, and create folders for each of the product teams. Within each folder, create separate projects for development, staging, and production environments.
You are storing billing reports in a storage bucket and need to grant read-only access to your finance team. What is the best way to set this up?
Add the members of the finance team to a group, and grant the group the Storage Object Viewer role on the bucket containing the reports.
Your development team uses GitHub to manage their code. You need to perform debugging tasks to resolve an error that was recently reported by the QA team. What should you do?
Set up Cloud Debugger, create a snapshot, and set log points.