Env vars in the Pod show the literal text `$(DB_HOST):5432` instead of the value.
IntermediateTroubleshootingPod startup failures
Answer
Likely causes → Kubernetes $(VAR) expansion only works for variables defined earlier in the same container's env list. If DB_HOST comes from envFrom defined after, or is defined later in the list, or does not exist, the literal string is kept.
Diagnose →
kubectl exec web-x -- printenv | grep DB_
kubectl get pod web-x -o jsonpath='{.spec.containers[0].env}' | jq
Fix → Define DB_HOST before the variable that uses it:
env:
- name: DB_HOST
valueFrom: {configMapKeyRef: {name: app, key: db_host}}
- name: DB_URL
value: "postgres://$(DB_HOST):5432/app"
Prevent → Build composite values in the app or in templating, not with runtime expansion chains.
More on Pod startup failures
A Pod shows `CrashLoopBackOff` with `RESTARTS 7` and events say `Back-off restarting failed container app`. Where do you start?Beginner`kubectl logs web-0 --previous` returns nothing useful and the container dies in under a second. How do you get inside it?IntermediatePod status is `ImagePullBackOff` and events show `Failed to pull image "registry.example.com/web:1.4.2": rpc error: code = NotFound desc = failed to pull and unpack image ... not found`.BeginnerEvents show `pull access denied for registry.example.com/web, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed`.BeginnerPulls from Docker Hub randomly fail with `toomanyrequests: You have reached your pull rate limit`.IntermediateA private registry with an internal CA fails with `x509: certificate signed by unknown authority` during image pull.Intermediate