← Back to all fixes

Secret value is empty or unavailable in pod

The Issue

You defined an env var from a Secret in your Deployment, but inside the pod the variable is empty.

Root Cause

Secret does not exist in the same namespace, key name is wrong, or Secret was not base64 encoded correctly when created manually.

How to Fix
  1. Verify the secret exists: `kubectl get secret <secret-name> -n <namespace>`
  2. Check the key: `kubectl get secret <secret-name> -o jsonpath="{.data}" | python3 -m json.tool`
  3. Decode to verify value: `kubectl get secret <secret-name> -o jsonpath="{.data.MY_KEY}" | base64 -d`
  4. Ensure namespace matches — secrets are namespace-scoped
  5. After fixing the secret, restart the deployment: `kubectl rollout restart deployment/<name>`