kubectl is the control surface for everything in a cluster. This page groups commands the way you'll actually reach for them — inspecting state, shipping a change, and digging into a failure.
Cluster Information
kubectl cluster-infoShows the control plane and core service endpoints for the current context.
kubectl config current-contextPrints which cluster/user/namespace kubectl is currently pointed at.
kubectl config get-contextsLists every cluster context available in your kubeconfig.
kubectl config use-context CONTEXT_NAMESwitches the active context — the cluster every subsequent command targets.
Nodes
kubectl get nodesLists cluster nodes and their Ready status.
kubectl get nodes -o wideAdds internal/external IP, OS image and container runtime per node.
kubectl describe node NODE_NAMEShows capacity, allocatable resources, conditions and the pods scheduled on a node.
kubectl top nodeShows live CPU/memory usage per node. Requires the metrics-server add-on.
Pods
kubectl get podsLists pods in the current namespace.
kubectl get pods -ALists pods across every namespace.
kubectl get pods -o wideAdds pod IP and the node it's scheduled on.
kubectl get pods --watchStreams pod status changes live instead of a single snapshot.
kubectl describe pod POD_NAMEShows full pod detail: containers, events, volumes, conditions — usually the first move when a pod misbehaves.
kubectl delete pod POD_NAMEDeletes the pod. If it's managed by a Deployment or ReplicaSet, a replacement is scheduled immediately — often the fastest way to force a clean restart.
Deployments
kubectl get deploymentsLists deployments and their desired/current/up-to-date/available replica counts.
kubectl describe deployment DEPLOYMENT_NAMEShows rollout strategy, replica status and recent events for a deployment.
kubectl scale deployment DEPLOYMENT_NAME --replicas=5Changes the desired replica count directly.
kubectl set image deployment/DEPLOYMENT_NAME CONTAINER_NAME=IMAGE:TAGUpdates a deployment's container image, triggering a rolling update.
Services & Ingress
kubectl get svcLists services and their type, cluster IP and exposed ports.
kubectl describe svc SERVICE_NAMEShows the service's selector and its resolved endpoints — the fastest way to confirm it's actually matching any pods.
kubectl get endpoints SERVICE_NAMELists the pod IPs a service currently routes to. Empty output means the selector isn't matching any ready pod.
kubectl get ingressLists ingress resources and the hosts/paths they route.
kubectl describe ingress INGRESS_NAMEShows backend resolution and recent events for an ingress — useful when a host routes but 404s or 502s.
ConfigMaps & Secrets
kubectl get configmapsLists ConfigMaps in the current namespace.
kubectl create configmap my-config --from-file=config.yamlCreates a ConfigMap from a local file.
kubectl get secretsLists Secrets in the current namespace (values are not shown).
kubectl get secret SECRET_NAME -o jsonpath='{.data.password}' | base64 -dDecodes a single key from a Secret. Secret data is base64-encoded, not encrypted at this layer.
Logs
kubectl logs POD_NAMEPrints a pod's current container logs.
kubectl logs -f POD_NAMEStreams logs live as they're written.
kubectl logs POD_NAME --previousShows logs from the container's previous run — essential after a crash, since the current container has no history yet.
kubectl logs POD_NAME -c CONTAINER_NAMETargets one container in a multi-container pod.
Exec & Debugging
kubectl exec -it POD_NAME -- /bin/bashOpens an interactive shell inside a running container.
kubectl exec POD_NAME -- envRuns a single command inside the container without an interactive shell.
kubectl debug POD_NAME -it --image=busyboxAttaches an ephemeral debug container to a running pod — useful when the pod's own image has no shell.
kubectl port-forward pod/POD_NAME 8080:80Forwards a local port to a port on the pod, for reaching a service directly without going through its Service object.
Resource Usage
kubectl top podsShows live CPU/memory usage per pod in the current namespace. Requires metrics-server.
kubectl top pods --containersBreaks usage down per container instead of summing per pod.
Rollouts
kubectl rollout status deployment/DEPLOYMENT_NAMEWatches a rollout until it completes or stalls.
kubectl rollout history deployment/DEPLOYMENT_NAMELists revisions for a deployment.
kubectl rollout undo deployment/DEPLOYMENT_NAMERolls back to the previous revision immediately.
kubectl rollout restart deployment/DEPLOYMENT_NAMERestarts every pod in a deployment with a fresh rolling update, without changing the image or config.
Labels & Namespaces
kubectl get pods -l app=webFilters pods by label selector.
kubectl label pod POD_NAME env=stagingAdds or updates a label on a resource.
kubectl get namespacesLists all namespaces in the cluster.
kubectl config set-context --current --namespace=my-namespaceSets the default namespace for the current context, so you stop typing -n on every command.
RBAC
kubectl get roles,rolebindings -n NAMESPACELists namespace-scoped roles and their bindings.
kubectl get clusterroles,clusterrolebindingsLists cluster-wide roles and their bindings.
kubectl auth can-i delete pods --as=system:serviceaccount:default:my-saChecks whether a given identity is permitted an action — the fastest way to debug a Forbidden error.
Storage
kubectl get pv,pvcLists PersistentVolumes and PersistentVolumeClaims and their Bound/Pending status.
kubectl describe pvc PVC_NAMEShows why a claim is still Pending — usually no matching StorageClass or provisioner, or insufficient capacity.
Helm
Helm packages and versions Kubernetes manifests as charts. See the dedicated Helm cheat sheet for install, upgrade and rollback commands.
Debugging
kubectl get events --sort-by=.lastTimestampLists cluster events newest-last — scheduling failures, image pull errors and probe failures all show up here before they show up in logs.
kubectl get all -n NAMESPACELists every common resource type in a namespace in one shot — a fast first look at what's actually running.
See the Kubernetes Troubleshooting tab for CrashLoopBackOff, ImagePullBackOff, stuck Pending pods, probe failures and more, each with a step-by-step diagnostic sequence.