Bitzu

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

Single choice

What is the workload identity pool name for a project with ID acme-prod?

  1. acme-prod.svc.id.goog
  2. acme-prod.iam.gserviceaccount.com
  3. svc.id.goog/acme-prod
  4. 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.

Select all that apply

Which are true when enabling the feature on a GKE Standard cluster?

  1. The cluster must be updated with --workload-pool=PROJECT_ID.svc.id.goog
  2. Node pools must use the GKE_METADATA metadata mode
  3. Autopilot clusters already have it enabled
  4. A service account key must be mounted as a Kubernetes secret
  5. 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

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.

Download on the App StoreGet it on Google Play

More Associate Cloud Engineer topics in this module