Debug Kubernetes Cluster: troubleshooting commands

33 commands in 4 groups: Events, Live Debug, Cluster Health, API Discovery. Click or tap any command to copy it. Official documentation: kubernetes.io.

Open in the interactive cheat sheet search, stars and every other section

Events

Inspect cluster events such as warnings, restarts, and scheduling failures to understand what happened to resources.
kubectl events --watch --types=Warning
Stream warning events live
kubectl events -n <namespace> --types=Warning
Modern events CLI: filter by Warning type
kubectl get events --field-selector=involvedObject.name=<name>
Events for a specific object
kubectl get events --field-selector=type=Warning
Only Warning events
kubectl get events -n <namespace>
Events in a Namespace
kubectl get events -A --sort-by='.metadata.creationTimestamp'
All events sorted by time
kubectl get events -n <namespace> --watch
Stream events in real time

Live Debug

Spawn ephemeral containers, debug copies of Pods, or get a privileged shell on a Node without restarting the original workload.
kubectl debug -it <pod> --image=<nonroot-image> --profile=restricted
Restricted PSS profile (non-root, all caps dropped), needs an image that runs as non-root
kubectl debug -it <pod> --image=alpine --profile=baseline
Profile compatible with the baseline Pod Security Standard
kubectl debug -it <pod> --image=alpine --profile=netadmin
Debug with NET_ADMIN and NET_RAW capabilities
kubectl debug -it <pod> --image=alpine --profile=sysadmin
Privileged debug container (sysadmin profile)
kubectl debug node/<node> -it --image=busybox --profile=sysadmin
Privileged shell on a Node in host namespaces, host root mounted at /host
kubectl debug -it <pod> --image=nicolaka/netshoot --target=<container> --profile=general
Ephemeral container sharing the target container PID namespace, ideal for distroless images
kubectl debug <pod> -it --image=busybox --copy-to=<debug-pod> --profile=general
Debug copy of a Pod, the original keeps running untouched
kubectl debug <pod> -it --image=busybox --copy-to=<debug-pod> --share-processes --profile=general
Debug copy with shared PID namespace between debug and target containers

Cluster Health

Check API Server reachability, Control Plane component statuses, and version compatibility.
kubectl cluster-info
Show API Server and DNS endpoints
kubectl cluster-info dump
Cluster state dump (kube-system and current Namespace) to stdout
kubectl get apiservices
APIService resources and their availability state
kubectl get --raw='/livez?verbose'
API Server liveness probe with per-check breakdown
kubectl get --raw='/readyz?verbose'
API Server readiness probe with per-check breakdown
kubectl get pods -n kube-system
Status of all kube-system Pods (Control Plane, DNS, CNI)
kubectl get pods -A --sort-by='.metadata.creationTimestamp'
All Pods sorted by creation time
kubectl get pods -A | grep -v Running
Show all non-Running Pods cluster-wide
kubectl logs -n kube-system <pod>
Logs of a Control Plane component (apiserver, scheduler…)
kubectl logs -n kube-system <pod> --previous
Logs from a crashed Control Plane container
kubectl version
Client and server versions

API Discovery

Discover what resources the cluster exposes and inspect their schemas. Mirrored from Cluster Health for in-flow debugging.
kubectl api-resources
List all available API resources
kubectl api-resources --api-group=<group>
Resources in a specific API group
kubectl api-resources --namespaced=false
Cluster-scoped resources only
kubectl api-resources --namespaced=true
Namespace-scoped resources only
kubectl explain <resource>
Describe a resource and its top-level fields
kubectl explain <resource>.spec.<field>
Explain a specific nested field
kubectl explain <resource> --recursive
Show full nested field tree