Cloud Run Flashcards

1
Q

What is Cloud Run?

A

Cloud Run is a serverless CaaS solution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the 2 ways to run your application on Cloud Run?

A

You can run your application as as Service or as a Job.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the feature differences between a Service and a Job?

A

The only difference is that a Job cannot run continuously like a Service that has CPU always allocated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the billing structure for a Service?

A

A Service is billed differently depending on which CPU mode is selected.

If CPU is only allocated when processing requests, you are billed for CPU, memory, and per request.
If CPU is always on, you are billed for CPU and memory.

The former is priced a bit higher than the latter, but is not always on. This could help offset costs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the billing structure for a Job?

A

A Job is billed the same way as a Service with CPU always allocated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Since Cloud Run is built on Knative, it is important to understand it. Give a quick summary of the components that make up Knative.

A

Knative is software that allows you to build and deploy serverless applications on Kubernetes.

Knative has 3 components:
1. Build
2. Serving
3. Eventing

We will only focus on the Serving component.
The Serving component is made up of 4 subcomponents:
1. Service
2. Route
3. Configuration
4. Revision

The Service component is responsible for creating and managing the Route and Configuration. The Route component maps a network endpoint to one or more Revisions. The Configuration component creates and manages Revisions. A Revision is an immutable snapshot version of one or more containers and configuration data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Cloud Run supports container images built for which OS architecture?

A

Linux 64-bit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the different ways to deploy an application as a Cloud Run Service?

A
  1. Container images in Artifact Registry or Docker Hub
  2. Continuous deployment from GitHub which requires Cloud Build
  3. Source code by using gcloud run deploy <service-name> --source <source-path>

When you deploy from source, if a Dockerfile exists, it will be used. If not, a buildpack will be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If a Cloud Run Service has multiple containers, can they all receive traffic?

A

No. There is only one container that defines a port and that is where traffic is routed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which service account does Cloud Run use by default?

A

The Compute Engine service account which has an editor role.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Does Cloud Run support gRPC?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Is Cloud Run a global or regional resource?

A

Cloud Run is a regional resource and its instances are spread across multiple zones within a region.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the different stages in the lifecycle of a Cloud Run instance and do they consume CPU?

A
  1. Startup
  2. Processing requests
  3. Idle
  4. Shutdown
  5. Forced termination

Startup consumes CPU.

Processing Requests consumes CPU.

Idle does not consume CPU when “CPU is only allocated when processing requests” mode is on. Else, consumes CPU.

Shutdown consumes CPU.

Forced termination consumes CPUand does not allow you to terminate your application gracefully.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Is it possible to gracefully shutdown an application during a Forced Termination?

A

No. A Forced Termination occurs when an application crashes or memory limits are exceed and cannot be handled gracefully. During Shutdown however, a SIGTERM signal is sent to the application which gives you 10 seconds to handle it and implement a graceful shutdown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

At what CPU utilization does Cloud Run create a new instance?

A

Whenever an existing instance reaches 60% CPU utilization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When you deploy a container image for the first time to Cloud Run, a service, and its first revision is created. Each service has a unique and permanent HTTPS endpoint URL that does not
change over time.

A
17
Q

Does Cloud Run support concurrency?

A

Yes. Each instance can be configured to handle up to 1000 requests at the same time.

18
Q

What is the billing structure of a Cloud Run Service that has CPU only allocated when processing requests but has 1 minimum instance running at all times?

A

The minimum instance is billed at the same rate as CPU is always on, but the other instances are billed at the same rate as CPU is only allocated when processing requests.

19
Q

Does Cloud Run pull container images from a repository every time it needs to scale out instances?

A

No. When Cloud Run pulls a container image for the first time, it creates a copy locally and uses it when scaling out instances.

20
Q

When using a Dockerfile that defines environment variables to build and deploy a container on Cloud Run, and Cloud Run also specifies its own environment variables, which environment variables will be used?

A

The environment variables defined by Cloud Run will be used. This is because Cloud Run environment variables override the environment variables defined in the Dockerfile.

21
Q

What are the 2 primary ways for accessing managed secrets when using Cloud Run?

A
  1. Environment variables
  2. Volumes

Secrets accessed as environment variables are static and an application will not be able to retrieve a newer version after startup. Therefore, secrets accessed as environment variables are normally pinned to a version.

Secrets accessed through a volume are dynamic and an application will always fetch the latest version by reading the secret (file) from the volume.

Remember, a volume is an external directory that is mounted to an internal directory inside your container.

22
Q

Does Cloud Run require a container image from Artifact Registry or Docker Hub to deploy an application?

A

Yes. In fact, even if you deploy from source, gcloud automatically stores the built image in Artifact Registry. However, since Cloud Run caches the image when deploying it, you can delete the image from Artifact Registry after it is deployed to prevent storage costs associated with Artifacr Registry.

23
Q

If there is a need to route the same client to the same instance, which Cloud Run feature could you use?

A

You can enable Session Affinity. Keep in mind, this is done on a best effort basis. You should also be aware that using Session Affinity with split traffic can lead to unique routing behavior. Make sure to read the documentation.

24
Q

If there is a need to route your egress traffic from your Cloud Run service to an internal GCP service (internal IP address) that uses your VPC Network (Memorystore), what are the 2 different ways to do so?

A
  1. Serverless VPC Access connectors
  2. Direct VPC

Serverless VPC Access allows Cloud Functions, Cloud Run, and App Engine standard environment apps to access resources in a VPC network using the internal IP addresses of those resources.

Direct VPC is more efficient but might require more configuration and appears to be a newer technology.

25
Q

The two types of tokens you can fetch with the metadata server are as follows:

OAuth 2.0 access tokens, which are used to call most Google API Client Libraries.
ID tokens, which are used to call other Cloud Run services or Cloud Functions, or to invoke any service to validate an ID token.

A