Kubernetes Pod Management
Overview
Inspect pod status, health, events, and resource usage across cluster environments.
Pod Status
List pods for a service
kubectl --context=<env> get pods -n <namespace> | grep <service>
List all pods in a namespace with status
kubectl --context=<env> get pods -n <namespace> -o wide
Check for unhealthy pods
kubectl --context=<env> get pods -n <namespace> | grep -v "Running\|Completed"
Diagnostics
Pod details and events
kubectl --context=<env> describe pod <pod> -n <namespace> | tail -30
Events show recent scheduling, pulling, starting, and crash info.
Check restart counts
kubectl --context=<env> get pods -n <namespace> -o custom-columns=\
NAME:.metadata.name,STATUS:.status.phase,RESTARTS:.status.containerStatuses[0].restartCount,\
AGE:.metadata.creationTimestamp | grep <service>
Pod resource usage
kubectl --context=<env> top pods -n <namespace> | grep <service>
Environment variables (non-secret)
kubectl --context=<env> exec -n <namespace> <pod> -- env | grep -iv "pass\|secret\|token\|key" | sort
Check which image/version is running
kubectl --context=<env> get pod <pod> -n <namespace> \
-o jsonpath='{.spec.containers[0].image}'
The image tag is the GitHub Actions run ID (databaseId). To find which PR/commit it corresponds to:
# Cross-reference image tag with CI runs on main
gh run list --repo <org>/<repo> --branch main --json databaseId,displayTitle,headSha \
| jq '.[] | select(.databaseId == <image-tag>)'
Common Namespaces
Read namespace names from the project's CLAUDE.md (## Infrastructure section). Typical patterns:
- Application services: one namespace per cluster (e.g.
plataformadato) - Shared infrastructure (RabbitMQ, monitoring): separate namespace (e.g.
shared-infra)
Rollout Management
Check deployment status
kubectl --context=<env> get deploy -n <namespace> | grep <service>
Restart a deployment (rolling)
⚠️ ALWAYS ask for explicit confirmation before running this command, in any environment. State clearly: what deployment will restart, in which environment, and what the impact is (brief downtime during rollout). Do NOT run without the user saying "yes", "proceed", or equivalent.
kubectl --context=<env> rollout restart deployment/<deployment> -n <namespace>
Check rollout history
kubectl --context=<env> rollout history deployment/<deployment> -n <namespace>