Troubleshooting
Step 3: Read the Logs
Events tell you what Kubernetes sees. Logs tell you what the application sees. For a crashing container, use --previous to see the last run's output.
# Logs from the crashed container
kubectl logs api-server -n production --previous
# Example output that tells us the problem:
Starting API server on port 8080...
Connecting to database at postgres.db.svc:5432...
ERROR: FATAL: password authentication failed for user "admin"
ERROR: Cannot connect to database. Exiting.
The answer is clear: the database password is wrong. The fix might be updating a Secret or ConfigMap.
⚠️
Common pitfall: If logs show nothing (container crashes instantly), the problem might be the command/entrypoint. Use kubectl describe to check the container's command, args, and image.