Interview Prep/Kubernetes/Pod startup failures

`kubectl logs api-7f9b` fails with `error: a container name must be specified for pod api-7f9b, choose one of: [app istio-proxy] or one of the init containers: [istio-init]`.

BeginnerTroubleshootingPod startup failures
Answer

Likely causes → Not an outage, just a multi-container Pod (service mesh sidecar, log shipper). kubectl needs to know which container you want.

Diagnose →

kubectl get pod api-7f9b -o jsonpath='{.spec.containers[*].name}'

Fix →

kubectl logs api-7f9b -c app
kubectl logs api-7f9b --all-containers --prefix
kubectl logs -l app=api -c app --max-log-requests=10 -f

Add the annotation kubectl.kubernetes.io/default-container: app on the Pod template so -c is not needed.

Prevent → Set the default-container annotation in your base Helm chart.

All Kubernetes questions Roadmap: Kubernetes core

More on Pod startup failures