Kubernetes Cheat Sheet
Essential kubectl commands and Kubernetes workflows for inspecting workloads, debugging rollouts, and operating clusters safely.
Cluster Info
6 commandskubectl cluster-infoCluster endpoint info
kubectl get nodesList all nodes
kubectl get nodes -o wideNodes with IPs and OS
kubectl top nodesNode resource usage
kubectl api-resourcesAll resource types
kubectl get all -AEverything in all namespaces
Pod Management
10 commandskubectl get podsList pods in current ns
kubectl get pods -APods in all namespaces
kubectl get pods -o widePods with node/IP info
kubectl describe pod NAMEDetailed pod info
kubectl logs NAMEPod logs
kubectl logs NAME --previousCrashed container logs
kubectl logs NAME -fStream logs (follow)
kubectl exec -it NAME -- bashShell into pod
kubectl delete pod NAMEDelete a pod
kubectl run debug --image=busybox -it --rm -- shQuick debug pod
Deployments
7 commandskubectl get deploymentsList deployments
kubectl create deploy NAME --image=IMGCreate deployment
kubectl scale deploy NAME --replicas=3Scale replicas
kubectl rollout status deploy/NAMEWatch rollout
kubectl rollout undo deploy/NAMERollback deploy
kubectl rollout history deploy/NAMERollout history
kubectl set image deploy/NAME c=img:v2Update image
Services & Networking
6 commandskubectl get svcList services
kubectl expose deploy NAME --port=80Create service
kubectl get endpoints NAMEService endpoints
kubectl get ingressList ingress rules
kubectl port-forward svc/NAME 8080:80Local port forward
kubectl get networkpolicyNetwork policies
Config & Secrets
5 commandskubectl get configmapList ConfigMaps
kubectl get secretList Secrets
kubectl create secret generic NAME --from-literal=k=vCreate secret
kubectl create configmap NAME --from-file=fCreate from file
kubectl get secret NAME -o jsonpath='{.data.key}' | base64 -dDecode secret
Debugging
6 commandskubectl describe pod NAMEEvents + status
kubectl get events --sort-by=.lastTimestampRecent events
kubectl top podsCPU/memory usage
kubectl get pods --field-selector=status.phase=FailedFailed pods
kubectl run debug --image=nicolaka/netshoot -it --rm -- bashNetwork debug pod
kubectl auth can-i create podsCheck permissions
Contexts & Namespaces
5 commandskubectl config get-contextsList contexts
kubectl config use-context NAMESwitch context
kubectl config set-context --current --namespace=NSSet default ns
kubectl get nsList namespaces
kubectl create ns NAMECreate namespace
Apply & Delete
5 commandskubectl apply -f file.yamlCreate/update resource
kubectl delete -f file.yamlDelete resource
kubectl apply -k ./dirApply kustomization
kubectl diff -f file.yamlPreview changes
kubectl delete pod --allDelete all pods
RBAC & Security
7 commandskubectl get clusterrolesList cluster roles
kubectl get rolebindings -AAll role bindings
kubectl auth can-i create pods --as userTest permissions
kubectl create sa my-saCreate service account
kubectl get pspPod security policies
kubectl get networkpolicy -AAll network policies
kubectl create secret tls NAME --cert=c --key=kCreate TLS secret
Autoscaling
6 commandskubectl autoscale deploy NAME --min=2 --max=10 --cpu-percent=80Create HPA
kubectl get hpaList horizontal pod autoscalers
kubectl describe hpa NAMEHPA details + events
kubectl get vpaVertical pod autoscalers
kubectl get nodeclaimsKarpenter-managed nodes
kubectl get nodepoolKarpenter node pools
Helm
9 commandshelm repo add NAME URLAdd chart repository
helm search repo nginxSearch for charts
helm install NAME chart --namespace nsInstall release
helm upgrade NAME chartUpgrade release
helm rollback NAME 1Rollback to revision
helm list -AAll releases
helm uninstall NAMEDelete release
helm template NAME chartRender templates locally
helm show values chartShow default values
CRDs & Custom Resources
6 commandskubectl get crdList custom resource definitions
kubectl get crd NAME -o yamlCRD definition
kubectl get RESOURCE -AList custom resources
kubectl explain RESOURCE.specShow resource schema
kubectl api-versionsAll API versions
kubectl api-resources --verbs=list --namespacedNamespaced resources
Advanced Debugging
8 commandskubectl debug pod/NAME -it --image=busyboxEphemeral debug container
kubectl run debug --image=nicolaka/netshoot -it --rm -- bashNetwork debug pod
kubectl get events --sort-by=.lastTimestamp -ACluster-wide events
kubectl get pod NAME -o jsonpath='{.status.conditions}'Pod conditions
kubectl logs -l app=NAME --all-containersLogs by label
kubectl cp pod:/path ./localCopy from pod
kubectl attach pod/NAME -c container -itAttach to process
kubectl proxyAPI server proxy (localhost:8001)
Jobs & CronJobs
6 commandskubectl create job NAME --image=img -- cmdCreate one-time job
kubectl get jobsList jobs
kubectl get cronjobsList cron jobs
kubectl create job test --from=cronjob/NAMEManual trigger
kubectl delete job NAMEDelete job + pods
kubectl logs job/NAMEJob logs