Interview Prep/DevSecOps/Cloud identity: IRSA, Workload Identity and CI OIDC

A GKE pod gets `403 ... does not have storage.objects.get access`, and the logs show it is using the node's Compute Engine default service account

IntermediateTroubleshootingCloud identity: IRSA, Workload Identity and CI OIDC
Answer

Likely causes → Workload Identity is not enabled on the node pool (metadata mode is not GKE_METADATA), or the KSA is not mapped to an IAM identity.

Diagnose →

gcloud container node-pools describe default --cluster prod --region asia-south1 \
  --format='value(config.workloadMetadataConfig.mode)'
kubectl run t --rm -it --image=google/cloud-sdk:slim --overrides='{"spec":{"serviceAccountName":"api"}}' -n prod \
  -- curl -s -H 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email

Fix → Update the node pool with --workload-metadata=GKE_METADATA, then grant the permission either to the KSA principal directly (principal://iam.googleapis.com/projects/<num>/locations/global/workloadIdentityPools/<proj>.svc.id.goog/subject/ns/prod/sa/api) or to a GSA that the KSA impersonates.

Prevent → Create clusters with Workload Identity on, and remove broad roles from the default compute SA.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Cloud identity: IRSA, Workload Identity and CI OIDC