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

Pods annotated with `vault.hashicorp.com/agent-inject: true` start without a Vault sidecar, and the app fails on a missing file

BeginnerTroubleshootingSecrets management: Vault, External Secrets and SOPS
Answer

Likely causes → The injector's mutating webhook is not running or does not select the namespace. Or the annotation sits on the Deployment metadata instead of the pod template. Or the value is not a quoted string. Because the webhook uses failurePolicy: Ignore, the pod is admitted unmutated.

Diagnose →

kubectl get mutatingwebhookconfiguration vault-agent-injector-cfg -o yaml | yq '.webhooks[].namespaceSelector'
kubectl logs -n vault deploy/vault-agent-injector | tail
kubectl get deploy api -o yaml | yq '.spec.template.metadata.annotations'

Fix → Put the annotations under spec.template.metadata.annotations, write "true" with quotes, then roll out the Deployment again. Mutations only happen at pod creation.

Prevent → Add a policy that fails pods carrying the inject annotation but no vault-agent container.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Secrets management: Vault, External Secrets and SOPS