Associate Cloud Engineer ยท Impersonation, short-lived credentials and workload identity
Workload Identity Federation for GKE
Workload Identity Federation for GKE: Kubernetes service account to IAM principal, annotating, binding, versus node service account usage.
Key points
- Lets pods authenticate to Google Cloud as their Kubernetes service account (KSA).
- Pool: PROJECT_ID.svc.id.goog (always on in Autopilot; Standard needs --workload-pool and GKE_METADATA node pools).
- Direct: roles on the KSA principal (principal://...), no annotation.
- Alternative: annotate KSA with iam.gke.io/gcp-service-account, grant roles/iam.workloadIdentityUser on the IAM service account.
- Replaces node service accounts and mounted keys.
Source: https://docs.cloud.google.com/kubernetes-engine/docs/how-to/workload-identity
Practice questions
What is the workload identity pool name for a project with ID acme-prod?
- acme-prod.svc.id.goog
- acme-prod.iam.gserviceaccount.com
- svc.id.goog/acme-prod
- acme-prod.pool.gke.io
Show answer
Answer: A. acme-prod.svc.id.goog
The pool follows PROJECT_ID.svc.id.goog, so acme-prod.svc.id.goog. The other forms are not the GKE pool format.
Which are true when enabling the feature on a GKE Standard cluster?
- The cluster must be updated with --workload-pool=PROJECT_ID.svc.id.goog
- Node pools must use the GKE_METADATA metadata mode
- Autopilot clusters already have it enabled
- A service account key must be mounted as a Kubernetes secret
- Pods must be rewritten to call a special GKE-only client library
Show answer
Answer: A. The cluster must be updated with --workload-pool=PROJECT_ID.svc.id.goog, B. Node pools must use the GKE_METADATA metadata mode, C. Autopilot clusters already have it enabled
Standard clusters need the workload pool set, node pools need GKE_METADATA so metadata calls reach the GKE metadata server, and Autopilot already has it on. A key is never needed.
True or false: when you grant roles directly to the Kubernetes service account's principal, you must still annotate the KSA with iam.gke.io/gcp-service-account.
Show answer
Answer: False
False. The annotation belongs to the alternative method that links a KSA to an IAM service account. With the principal identifier, the IAM allow policy alone is enough.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
