Skip to content
Latchkey

kubectl get pods: Inspect Pods in CI

List pods with their status, optionally filtered and formatted for scripts.

kubectl get pods lists pods and their phase, restarts, and age. In CI it is used to verify a deploy landed and to script checks (with -o jsonpath or labels). Combine selectors with output formats to assert on specific workloads.

Common flags

  • -n NAMESPACE / -A - namespace, or all namespaces
  • -l key=value - filter by label selector
  • -o wide / -o jsonpath=... - richer or scriptable output
  • --field-selector status.phase=Running - filter by field

Example in CI

Assert that all api pods are Running.

shell
kubectl get pods -n prod -l app=api \
  -o jsonpath='{.items[*].status.phase}'

Common errors in CI

  • No resources found in NAMESPACE namespace - wrong namespace or no matching pods
  • Unable to connect to the server - kubeconfig/context not set
  • Error from server (Forbidden): pods is forbidden - RBAC denies list on pods

Key takeaways

  • Lists pods with status; the go-to check after a deploy.
  • Use -l selectors with -o jsonpath to script assertions in CI.
  • Forbidden errors point to missing RBAC, not a bad command.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →