kubectl Cheatsheet 2026 — Searchable Command Reference

Complete kubectl cheatsheet with 100+ commands. Searchable and filterable by category — pods, deployments, services, debugging, RBAC, and more.

CommandDescriptionExample
kubectl get podsList all pods in current namespacekubectl get pods -n production
kubectl get pods -o wideList pods with node and IP infokubectl get pods -o wide -A
kubectl describe pod <name>Show pod details, events, and container statekubectl describe pod myapp-abc123
kubectl logs <pod>Print logs for a pod containerkubectl logs myapp-abc123 -c mycontainer -f
kubectl logs --previous <pod>Print logs from previous (crashed) containerkubectl logs --previous myapp-abc123
kubectl exec -it <pod> -- bashOpen interactive shell in podkubectl exec -it myapp-abc123 -- /bin/sh
kubectl port-forward pod/<name> 8080:80Forward local port to pod portkubectl port-forward pod/myapp-abc123 8080:8080
kubectl delete pod <name>Delete pod (will restart if managed by controller)kubectl delete pod myapp-abc123
kubectl top podsShow CPU/memory usage of podskubectl top pods -n production --sort-by=memory
kubectl cp <pod>:/path ./localCopy files from pod to localkubectl cp myapp-abc123:/app/logs ./logs
kubectl get pods -l app=<name>Filter pods by label selectorkubectl get pods -l app=myapp,env=prod
kubectl get pods --watchWatch pod status changes in real timekubectl get pods -n production --watch
kubectl annotate pod <name> key=valAdd or update annotation on a podkubectl annotate pod myapp team=backend
kubectl label pod <name> key=valAdd or update label on a podkubectl label pod myapp env=staging
kubectl get deploymentsList all deploymentskubectl get deployments -A
kubectl describe deployment <name>Show deployment details and eventskubectl describe deployment myapp
kubectl rollout status deployment/<name>Watch deployment rollout progresskubectl rollout status deployment/myapp
kubectl rollout history deployment/<name>View rollout historykubectl rollout history deployment/myapp --revision=2
kubectl rollout undo deployment/<name>Roll back to previous versionkubectl rollout undo deployment/myapp --to-revision=2
kubectl scale deployment/<name> --replicas=NScale deployment to N replicaskubectl scale deployment/myapp --replicas=5
kubectl set image deployment/<name> <container>=<image>Update container imagekubectl set image deployment/myapp app=myapp:v2.0
kubectl rollout restart deployment/<name>Rolling restart of all podskubectl rollout restart deployment/myapp
kubectl get deployment -o yamlExport deployment YAMLkubectl get deployment myapp -o yaml > myapp.yaml
kubectl apply -f <file>Apply or update resources from filekubectl apply -f deployment.yaml
kubectl delete deployment <name>Delete a deployment and its podskubectl delete deployment myapp
kubectl get replicasetsList ReplicaSets (managed by deployments)kubectl get rs -n production
kubectl set resources deployment/<name>Update resource requests/limitskubectl set resources deployment/myapp -c=app --limits=cpu=200m,memory=512Mi
kubectl get servicesList all serviceskubectl get svc -A
kubectl describe service <name>Show service details and endpointskubectl describe svc myapp
kubectl expose deployment <name>Create service from deploymentkubectl expose deployment myapp --port=80 --type=ClusterIP
kubectl port-forward svc/<name> 8080:80Forward local port to servicekubectl port-forward svc/myapp 8080:80
kubectl get endpoints <name>Show service endpoints (pod IPs)kubectl get endpoints myapp
kubectl get ingressList all Ingress resourceskubectl get ingress -A
kubectl describe ingress <name>Show Ingress rules and backend detailskubectl describe ingress myapp-ingress
kubectl delete svc <name>Delete a servicekubectl delete svc myapp
kubectl create configmap <name> --from-literal=key=valCreate ConfigMap from literal valuekubectl create configmap myconfig --from-literal=DB_HOST=localhost
kubectl create configmap <name> --from-file=<file>Create ConfigMap from filekubectl create configmap myconfig --from-file=config.yaml
kubectl get configmap <name> -o yamlView ConfigMap contentskubectl get configmap myconfig -o yaml
kubectl create secret generic <name> --from-literal=key=valCreate generic secretkubectl create secret generic mysecret --from-literal=password=secret123
kubectl get secret <name> -o jsonpathDecode secret valuekubectl get secret mysecret -o jsonpath='{.data.password}' | base64 -d
kubectl edit configmap <name>Edit ConfigMap in-placekubectl edit configmap myconfig -n production
kubectl create secret tls <name> --cert --keyCreate TLS secret from cert fileskubectl create secret tls mytls --cert=tls.crt --key=tls.key
kubectl get namespacesList all namespaceskubectl get ns
kubectl create namespace <name>Create a namespacekubectl create ns production
kubectl config set-context --current --namespace=<ns>Set default namespace for contextkubectl config set-context --current --namespace=production
kubectl get all -n <ns>List all resources in namespacekubectl get all -n production
kubectl delete namespace <name>Delete namespace and all its resourceskubectl delete ns old-environment
kubectl config get-contextsList all kubeconfig contextskubectl config get-contexts
kubectl config use-context <name>Switch to a different cluster contextkubectl config use-context prod-cluster
kubectl config current-contextShow the current context namekubectl config current-context
kubectl get events --sort-by=.lastTimestampList events sorted by timekubectl get events -n production --sort-by=.lastTimestamp
kubectl describe node <name>Show node details, conditions, and capacitykubectl describe node worker-node-1
kubectl run debug --image=busybox -it --rmRun temporary debug containerkubectl run debug --image=nicolaka/netshoot -it --rm -- bash
kubectl debug node/<name> -it --image=ubuntuDebug node with privileged containerkubectl debug node/worker-1 -it --image=ubuntu
kubectl get pods -o wide --field-selectorFilter pods by fieldkubectl get pods --field-selector=status.phase=Running
kubectl get pods --show-labelsShow pod labelskubectl get pods -n production --show-labels
kubectl apply --dry-run=client -f <file>Validate manifest without applyingkubectl apply --dry-run=client -f deployment.yaml
kubectl diff -f <file>Show diff between file and cluster statekubectl diff -f deployment.yaml
kubectl logs -l app=<name> --all-containersGet logs from all pods matching labelkubectl logs -l app=myapp --all-containers -n production
kubectl get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'Extract specific fields with JSONPathkubectl get pods -o jsonpath='{.items[*].status.podIP}'
kubectl auth can-i <verb> <resource>Check if current user can perform actionkubectl auth can-i create pods -n production
kubectl auth can-i --listList all actions current user can performkubectl auth can-i --list -n production
kubectl auth can-i --as=<user>Check permissions as another userkubectl auth can-i create pods --as=deploy-bot -n production
kubectl create role <name> --verb=<v> --resource=<r>Create a Rolekubectl create role deployer --verb=get,list,create --resource=pods
kubectl create rolebinding <name> --role=<r> --user=<u>Bind role to userkubectl create rolebinding deploy-binding --role=deployer --user=ci-bot
kubectl get clusterrolebindings -o wideList all ClusterRoleBindingskubectl get clusterrolebindings -o wide | grep myuser
kubectl create serviceaccount <name>Create a ServiceAccountkubectl create serviceaccount deploy-bot -n production
kubectl get roles -n <ns>List Roles in a namespacekubectl get roles -n production -o wide
kubectl describe clusterrole <name>Show ClusterRole rules in detailkubectl describe clusterrole cluster-admin
kubectl create clusterrolebinding <name> --clusterrole=<r> --user=<u>Bind ClusterRole to user cluster-widekubectl create clusterrolebinding admin-binding --clusterrole=cluster-admin --user=admin
kubectl get nodesList all cluster nodeskubectl get nodes -o wide
kubectl top nodesShow CPU/memory usage of nodeskubectl top nodes --sort-by=cpu
kubectl cordon <node>Mark node unschedulablekubectl cordon worker-node-1
kubectl drain <node>Drain node for maintenancekubectl drain worker-node-1 --ignore-daemonsets --delete-emptydir-data
kubectl uncordon <node>Re-enable scheduling on nodekubectl uncordon worker-node-1
kubectl versionShow client and server versionkubectl version --short
kubectl cluster-infoShow cluster endpoint and service URLskubectl cluster-info dump > cluster-dump.txt
kubectl taint nodes <node> key=val:NoScheduleAdd taint to nodekubectl taint nodes gpu-node gpu=true:NoSchedule
kubectl label nodes <node> key=valAdd label to nodekubectl label nodes worker-1 tier=production
kubectl get componentstatusesCheck health of cluster componentskubectl get cs
kubectl get storageclassesList available StorageClasseskubectl get sc
kubectl get pvList PersistentVolumes cluster-widekubectl get pv --sort-by=.spec.capacity.storage

Need expert Kubernetes help? Our certified K8s engineers at kubernetes.ae can review your cluster security and RBAC configuration. →

Get Expert Kubernetes Help

Talk to a certified Kubernetes expert. Free 30-minute consultation — actionable findings within days.

Talk to an Expert