kubectl Quick Reference
Common kubectl commands for managing Kubernetes clusters, namespaces, pods, services, and deployments.
Cluster Info
kubectl version
kubectl cluster-info
kubectl config view
kubectl config current-context
kubectl config use-context <context-name>
Namespaces
kubectl get namespaces
kubectl create namespace <name>
kubectl delete namespace <name>
Pods
kubectl get pods
kubectl get pods --all-namespaces
kubectl get pods -n <namespace>
kubectl describe pod <pod-name> -n <namespace>
kubectl logs <pod-name> -n <namespace>
kubectl exec -it <pod-name> -- bash
kubectl delete pod <pod-name>
Deployments
kubectl get deployments
kubectl get deployment <name> -n <namespace>
kubectl describe deployment <name>
kubectl scale deployment <name> --replicas=3
kubectl rollout status deployment/<name>
kubectl rollout undo deployment/<name>
Services
kubectl get services --all-namespaces
kubectl describe service <name> -n <namespace>
kubectl expose deployment <name> --port=80 --type=LoadBalancer
Apply / Delete Resources
kubectl apply -f manifest.yaml
kubectl delete -f manifest.yaml
kubectl delete pod <pod-name> --grace-period=0 --force
Nodes
kubectl get nodes
kubectl describe node <node-name>
kubectl cordon <node-name>
kubectl drain <node-name> --ignore-daemonsets
kubectl uncordon <node-name>