Kubernetes Cheatsheet
Complete kubectl command reference. Search, filter by category, and click to copy.
Kubernetes Cheatsheet
Essential kubectl commands for container orchestration
Commands
Categories
Favorites
Sections
kubectl cluster-infoDisplay cluster info
kubectl versionShow kubectl version
kubectl config viewShow kubeconfig
kubectl config get-contextsList contexts
kubectl config use-context [name]Switch context
kubectl config current-contextShow current context
kubectl get nodesList all nodes
kubectl get nodes -o wideNodes with details
kubectl describe node [name]Node details
kubectl top nodesNode resource usage
kubectl get nsList namespaces
kubectl create ns [name]Create namespace
kubectl delete ns [name]Delete namespace
kubectl config set-context --current --namespace=[ns]Set default namespace
kubectl get podsList pods
kubectl get pods -AAll namespaces
kubectl get pods -o wideWith node info
kubectl get pods -wWatch pods
kubectl get pods -l app=[label]Filter by label
kubectl describe pod [name]Pod details
kubectl logs [pod]Pod logs
kubectl logs -f [pod]Follow logs
kubectl logs [pod] -c [container]Container logs
kubectl logs --tail=100 [pod]Last 100 lines
kubectl exec -it [pod] -- bashShell into pod
kubectl exec [pod] -- [cmd]Run command
kubectl cp [pod]:/path /localCopy from pod
kubectl delete pod [name]Delete pod
kubectl run [name] --image=[img]Run pod
kubectl port-forward [pod] 8080:80Port forward
kubectl get deployList deployments
kubectl get deploy -o wideWith details
kubectl describe deploy [name]Deployment details
kubectl create deploy [name] --image=[img]Create deployment
kubectl scale deploy [name] --replicas=3Scale replicas
kubectl set image deploy/[name] [container]=[img]Update image
kubectl rollout status deploy/[name]Rollout status
kubectl rollout history deploy/[name]Rollout history
kubectl rollout undo deploy/[name]Rollback
kubectl rollout restart deploy/[name]Restart deployment
kubectl delete deploy [name]Delete deployment
kubectl edit deploy [name]Edit deployment
kubectl get rsList ReplicaSets
kubectl get dsList DaemonSets
kubectl get stsList StatefulSets
kubectl get jobsList Jobs
kubectl get cronjobsList CronJobs
kubectl get svcList services
kubectl get svc -o wideWith details
kubectl describe svc [name]Service details
kubectl expose deploy [name] --port=80Expose deployment
kubectl expose deploy [name] --type=NodePort --port=80NodePort service
kubectl expose deploy [name] --type=LoadBalancer --port=80LoadBalancer
kubectl delete svc [name]Delete service
kubectl port-forward svc/[name] 8080:80Port forward
kubectl get ingList ingresses
kubectl describe ing [name]Ingress details
kubectl get ing -AAll namespaces
kubectl get cmList ConfigMaps
kubectl describe cm [name]ConfigMap details
kubectl create cm [name] --from-literal=key=valCreate ConfigMap
kubectl create cm [name] --from-file=[file]From file
kubectl get secretsList secrets
kubectl describe secret [name]Secret details
kubectl create secret generic [name] --from-literal=key=valCreate secret
kubectl get secret [name] -o jsonpath='{.data}'Get secret data
kubectl get pvList PersistentVolumes
kubectl get pvcList PersistentVolumeClaims
kubectl describe pv [name]PV details
kubectl describe pvc [name]PVC details
kubectl get scList StorageClasses
kubectl get saList ServiceAccounts
kubectl get rolesList Roles
kubectl get rolebindingsList RoleBindings
kubectl get clusterrolesList ClusterRoles
kubectl get clusterrolebindingsList ClusterRoleBindings
kubectl auth can-i [verb] [resource]Check permissions
kubectl auth can-i --listList all permissions
kubectl apply -f [file.yaml]Apply config
kubectl delete -f [file.yaml]Delete from file
kubectl create -f [file.yaml]Create from file
kubectl get allList all resources
kubectl get all -AAll namespaces
kubectl api-resourcesList API resources
kubectl explain [resource]Resource docs
kubectl label pod [name] key=valueAdd label
kubectl label pod [name] key-Remove label
kubectl annotate pod [name] key=valueAdd annotation
kubectl get pods --show-labelsShow labels
kubectl cordon [node]Mark unschedulable
kubectl uncordon [node]Mark schedulable
kubectl drain [node]Drain node
kubectl taint node [node] key=val:NoScheduleAdd taint
kubectl get eventsList events
kubectl get events --sort-by='.lastTimestamp'Sorted events
kubectl top podsPod resource usage
kubectl describe pod [name] | grep -A5 EventsPod events
Quick Reference
kubectl get [resource]
kubectl describe [res]
kubectl logs [pod]
kubectl exec -it [pod] -- bash
About Kubernetes
Kubernetes (K8s) is an open-source container orchestration platform that automates deployment, scaling, and management of containerized applications.