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
kubectl describe: Debug Resources in CIShow detailed resource state and events in CI: usage, a debugging example, and the errors that indicate the w…
kubectl logs: Capture Container Logs in CIFetch container logs in CI: selector, previous, and tail flags, a debug example, and the errors you hit when…
kubectl wait: Block on Conditions in CIWait for a Kubernetes condition in CI: --for and --timeout flags, a readiness-gate example, and the timeout e…