Skip to content

Professional Cloud Developer · Domain 3: Configuring cloud-native applications for deployment · 24% of the exam

Task 3.2: Deploying containers to GKE.

Deploying containerized applications, Kubernetes health checks for availability, and Horizontal Pod Autoscaler scaling and metrics.

Study it

Sample questions

Try each one before opening the answer. Every option is explained, with the Google Cloud documentation page that proves it.

Question 1 · choose 1

A GKE cluster with Workload Identity Federation for GKE uses the Secret Manager add-on. Pods of the checkout Deployment in the namespace shop run as the Kubernetes ServiceAccount cart-ksa and mount a volume that refers to a SecretProviderClass listing the secret stripe-key. The Pods stay in ContainerCreating with a permission error on the volume. The team granted: gcloud secrets add-iam-policy-binding stripe-key \ --role=roles/secretmanager.secretAccessor \ --member=principal://iam.googleapis.com/projects/123456789012/locations/global/workloadIdentityPools/acme-prod.svc.id.goog/subject/ns/default/sa/cart-ksa What should the team do?

  1. AGrant the role to the cluster's node service account instead
  2. BGrant the role to serviceAccount:cart-ksa@acme-prod.iam.gserviceaccount.com
  3. CRecreate the SecretProviderClass in the namespace default
  4. DGrant the role to the principal whose path ends in ns/shop/sa/cart-ksa
Show the answer and why
  • AGrant the role to the cluster's node service account instead

    Incorrect

    The add-on authenticates with the workload identity of the Pod that mounts the secret, not the node's account.

  • BGrant the role to serviceAccount:cart-ksa@acme-prod.iam.gserviceaccount.com

    Incorrect

    cart-ksa is a Kubernetes ServiceAccount, not an IAM service account; IAM grants to it use the principal identifier.

  • CRecreate the SecretProviderClass in the namespace default

    Incorrect

    The Pods run in shop; moving the object doesn't grant their identity access to the secret.

  • DGrant the role to the principal whose path ends in ns/shop/sa/cart-ksa

    Correct

    The add-on uses the workload identity of the Pod, which is identified by its namespace and Kubernetes ServiceAccount.

The Secret Manager add-on mounts the secrets listed in a SecretProviderClass as files in Pod volumes. The Google Secret Manager provider uses the workload identity of the Pod that the secret is mounted onto, so the Secret Accessor role must go to the principal identifier that names the Pod's namespace and Kubernetes ServiceAccount: principal://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/PROJECT_ID.svc.id.goog/subject/ns/NAMESPACE/sa/KSA_NAME.

Question 2 · choose 1

Pods on a GKE cluster with Workload Identity Federation for GKE read a configuration file from Cloud Storage in their startup code, using the client library. Now and then a newly created Pod fails that first call with an authentication error and exits; the same Pod succeeds after it restarts, and running Pods never fail. What should the team change?

  1. ARetry the credential and Cloud Storage call for a few seconds at startup
  2. BSet hostNetwork: true so that the Pods reach the metadata server directly
  3. CGrant the Cloud Storage role to the node pool's service account as well
  4. DGrant the Cloud Storage role again to the Pods' Kubernetes ServiceAccount
Show the answer and why
  • ARetry the credential and Cloud Storage call for a few seconds at startup

    Correct

    The GKE metadata server needs a few seconds to accept requests on a new Pod, and retrying resolves the failure.

  • BSet hostNetwork: true so that the Pods reach the metadata server directly

    Incorrect

    Pods on the host network don't use Workload Identity Federation for GKE at all.

  • CGrant the Cloud Storage role to the node pool's service account as well

    Incorrect

    The Pods authenticate as their own workload identity; the node's account isn't used for these calls.

  • DGrant the Cloud Storage role again to the Pods' Kubernetes ServiceAccount

    Incorrect

    Running Pods with the same identity succeed, so the grant is in place; the failure comes from timing at Pod start.

With Workload Identity Federation for GKE, the GKE metadata server intercepts credential requests from Pods. It takes a few seconds to start accepting requests on a newly created Pod, so authentication attempts in the first seconds of a Pod's life might fail; retrying the call resolves the problem. Pods with hostNetwork: true don't use Workload Identity Federation for GKE.

Question 3 · choose 1

A web Deployment sits behind a GKE Ingress with container-native load balancing. The Ingress was created while the Pods had this probe: readinessProbe: httpGet: path: / port: 8080 The team later changed the probe's path to /healthz, and / now requires a login and answers 401. The load balancer marks every backend unhealthy, while kubectl shows all Pods Ready. Which change fixes the load balancer's health check without recreating the Ingress?

  1. AScale the Deployment to zero and back so that the Ingress reads the new probe
  2. BAttach a BackendConfig to the Service with a healthCheck whose requestPath is /healthz
  3. CAdd a livenessProbe on /healthz next to the readiness probe
  4. DChange the readiness probe's port to the Service port so that the load balancer picks up the new path
Show the answer and why
  • AScale the Deployment to zero and back so that the Ingress reads the new probe

    Incorrect

    The Ingress reads readiness probes when it is created; later probe changes don't affect it.

  • BAttach a BackendConfig to the Service with a healthCheck whose requestPath is /healthz

    Correct

    A BackendConfig healthCheck sets the load balancer's health check explicitly, whatever the Ingress inferred at creation.

  • CAdd a livenessProbe on /healthz next to the readiness probe

    Incorrect

    A liveness probe restarts containers; it doesn't change the load balancer's health check.

  • DChange the readiness probe's port to the Service port so that the load balancer picks up the new path

    Incorrect

    Changes to a Pod's readinessProbe don't affect the Ingress after it is created, whatever the port.

The GKE Ingress controller can use the Pods' readinessProbes as health checks only if the Pods exist when the Ingress is created, and changes to a Pod's readinessProbe don't affect the Ingress afterwards. To set the load balancer's health check explicitly, use a custom health check configuration in a BackendConfig, such as the requestPath, referenced from the Service.

Question 4 · choose 1

Pods of a Java service on GKE go into CrashLoopBackOff a few minutes after each rollout under load. The team suspects that its liveness probe restarts the containers. Where does GKE's troubleshooting guide say to confirm that liveness probe failures cause the restarts?

  1. AIn the kubelet logs of the nodes, by querying Logs Explorer for liveness-probe restart messages
  2. BIn the application's own stdout logs, by searching for requests to the probe's path on each of the Pods
  3. CIn the load balancer's request logs for the backend service of the Ingress
  4. DIn the Deployment's rollout history, which lists each probe failure
Show the answer and why
  • AIn the kubelet logs of the nodes, by querying Logs Explorer for liveness-probe restart messages

    Correct

    The kubelet runs the probe and restarts the container, and its logs record probe failures and the restarts that follow.

  • BIn the application's own stdout logs, by searching for requests to the probe's path on each of the Pods

    Incorrect

    The probe is run by the kubelet; the restart decision is logged by the kubelet, not by the app.

  • CIn the load balancer's request logs for the backend service of the Ingress

    Incorrect

    Liveness probes come from the kubelet on the node, not from the load balancer.

  • DIn the Deployment's rollout history, which lists each probe failure

    Incorrect

    Rollout history lists revisions of the Pod template, not probe results.

A liveness probe is a periodic health check performed by the kubelet; if it fails a specified number of times (three by default), the kubelet restarts the container. To confirm that liveness probes trigger CrashLoopBackOff events, GKE's guide says to query the kubelet logs in Logs Explorer for messages such as failed liveness probe, will be restarted.

Question 5 · choose 1

A Deployment on GKE scales with this autoscaler: apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: worker spec: scaleTargetRef: {apiVersion: apps/v1, kind: Deployment, name: worker} minReplicas: 3 maxReplicas: 40 metrics: - type: Resource resource: {name: cpu, target: {type: Utilization, averageUtilization: 60}} - type: External external: metric: {name: queue_depth} target: {type: AverageValue, averageValue: "30"} After a spike, the Deployment stayed at 40 replicas for hours although CPU use fell to 5%. kubectl describe hpa shows that the queue_depth metric is unavailable since its adapter was upgraded. What explains this?

  1. AThe autoscaler acts on the Deployment's old ReplicaSet, which the last rollout replaced
  2. BmaxReplicas acts as a floor once it has been reached during a spike
  3. CThe autoscaler doesn't scale down while any of its metrics is unavailable
  4. DCPU and external metrics can't be combined, so the autoscaler froze
Show the answer and why
  • AThe autoscaler acts on the Deployment's old ReplicaSet, which the last rollout replaced

    Incorrect

    scaleTargetRef names the Deployment itself, which is where autoscaling should be configured.

  • BmaxReplicas acts as a floor once it has been reached during a spike

    Incorrect

    maxReplicas is an upper bound; scaling down is still allowed.

  • CThe autoscaler doesn't scale down while any of its metrics is unavailable

    Correct

    With a metric unavailable, the autoscaler can still scale up but doesn't scale down.

  • DCPU and external metrics can't be combined, so the autoscaler froze

    Incorrect

    Several metrics can be combined; each is evaluated and the largest scale wins.

With several metrics, the horizontal Pod autoscaler evaluates each one and uses the largest resulting scale. If one or more metrics are unavailable, it still scales up based on the largest size calculated but doesn't scale down. Restoring the external metric, or removing it from the autoscaler, lets the Deployment scale down again.

Question 6 · choose 1

A Deployment on GKE runs three Pods of an older image tag. An engineer edits only spec.replicas from 3 to 5 and applies the manifest. What happens to the three running Pods?

  1. AThey keep running, and two more Pods are created; no rollout starts
  2. BThey are replaced one at a time in a rolling update, keeping the same image tag
  3. CThey are deleted and five new Pods start at once
  4. DThey pull the image tag again and restart
Show the answer and why
  • AThey keep running, and two more Pods are created; no rollout starts

    Correct

    Scaling or changing fields outside the Pod template doesn't trigger a rollout.

  • BThey are replaced one at a time in a rolling update, keeping the same image tag

    Incorrect

    A rollout starts only when the Pod template changes.

  • CThey are deleted and five new Pods start at once

    Incorrect

    A change to replicas only adds or removes Pods to match the count.

  • DThey pull the image tag again and restart

    Incorrect

    Nothing in the Pod template changed, so the Pods aren't recreated.

A rolling update of a Deployment is triggered by updating its Pod template, the spec: template field. Scaling a resource or updating fields outside the Pod template doesn't trigger a rollout; the Deployment only creates or removes Pods to reach the new replica count.

Question 7 · choose 1

A Deployment on a GKE 1.34 cluster has this liveness probe, and its Pods are healthy: livenessProbe: exec: command: ["/bin/sh", "-c", "/app/check.sh"] periodSeconds: 10 check.sh takes about four seconds to finish. What happens to these Pods after the cluster is upgraded to GKE version 1.35?

  1. AThe probe keeps passing, because GKE ignores timeoutSeconds for exec probe commands
  2. BThe probe keeps passing, because an omitted timeoutSeconds gives the command 10 seconds
  3. CThe probe fails after one second, and the containers are restarted
  4. DThe probe fails, but the failure only adds a warning event to each Pod
Show the answer and why
  • AThe probe keeps passing, because GKE ignores timeoutSeconds for exec probe commands

    Incorrect

    That was true only before GKE 1.35; from 1.35 the timeout of exec probe commands is enforced.

  • BThe probe keeps passing, because an omitted timeoutSeconds gives the command 10 seconds

    Incorrect

    If timeoutSeconds is omitted, the default is 1 second, not 10.

  • CThe probe fails after one second, and the containers are restarted

    Correct

    From 1.35 the 1-second default timeout applies; a liveness probe that times out fails, and the container is restarted.

  • DThe probe fails, but the failure only adds a warning event to each Pod

    Incorrect

    A warning event without a restart was possible only before 1.35; from 1.35 a timed-out liveness probe restarts the container.

Starting in GKE version 1.35, Kubernetes enforces the timeoutSeconds of commands in exec probes; before 1.35 it ignored that value. With the field omitted, the timeout is 1 second, so a four-second check fails. A failed liveness probe makes Kubernetes restart the container, and repeated failures can leave Pods in CrashLoopBackOff. Setting timeoutSeconds above the command's run time before upgrading avoids this.

Question 8 · choose 1

A horizontal Pod autoscaler on GKE targets 60% average CPU utilization. The workload runs at 64% for an hour, and the autoscaler doesn't add Pods. Why?

  1. AThe autoscaler scales up only above twice the target
  2. BThe ratio 64/60 is within the 10% tolerance, so no scaling action is taken
  3. CThe autoscaler acts only on memory unless CPU is listed twice in the metrics
  4. DUtilization targets apply only to Pods on Spot nodes
Show the answer and why
  • AThe autoscaler scales up only above twice the target

    Incorrect

    No such threshold exists; scaling follows the ratio to the target outside a 10% tolerance.

  • BThe ratio 64/60 is within the 10% tolerance, so no scaling action is taken

    Correct

    No scaling happens while the ratio of current to target value is within 10% of 1.0.

  • CThe autoscaler acts only on memory unless CPU is listed twice in the metrics

    Incorrect

    CPU utilization is a supported target in its own right.

  • DUtilization targets apply only to Pods on Spot nodes

    Incorrect

    Utilization targets apply to the workload's Pods whatever their nodes.

To prevent minor fluctuations from causing scaling events, the horizontal Pod autoscaler uses a tolerance of 10%: no scaling action is taken if the ratio of the current metric value to the target is within 10% of 1.0. A ratio of 64 to 60, about 1.07, is inside that band.

Practice domain 3 →Practice all domains →