Interview Prep/DevSecOps/Secrets management: Vault, External Secrets and SOPS

Pod stuck in `Init:0/1`; the `vault-agent-init` container logs `error authenticating: ... Code: 403 ... * permission denied`

IntermediateTroubleshootingSecrets management: Vault, External Secrets and SOPS
Answer

Likely causes → The Kubernetes auth role does not match the pod: wrong bound_service_account_names, wrong bound_service_account_namespaces, a wrong vault.hashicorp.com/role annotation, or a role that has no policy attached.

Diagnose →

kubectl get pod <pod> -o jsonpath='{.spec.serviceAccountName}{"\n"}{.metadata.annotations}'
vault read auth/kubernetes/role/api

Fix →

vault write auth/kubernetes/role/api \
  bound_service_account_names=api \
  bound_service_account_namespaces=prod \
  policies=api-read ttl=1h

Prevent → Manage roles in Terraform next to the Deployment's ServiceAccount, and give each workload its own SA. Never use default.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Secrets management: Vault, External Secrets and SOPS