Kubernetes Cheat Sheet
Kubernetes (K8s) is a container orchestration platform for deploying, scaling, and operating containerized applications. This cheatsheet consolidates official Kubernetes documentation and common operational patterns into a single advanced reference.
Core Concepts
- Cluster, Node, Pod
- Namespace
- Label / Selector
- Annotation
kubectl Basics
kubectl version
kubectl cluster-info
kubectl config get-contexts
kubectl config use-context <context>
kubectl api-resources
kubectl explain pod.spec
Viewing Resources
kubectl get nodes
kubectl get pods -o wide
kubectl describe pod <pod>
kubectl top node
kubectl top pod
Workloads
kubectl create deployment web --image=nginx
kubectl scale deployment web --replicas=3
kubectl rollout status deployment web
kubectl rollout undo deployment web
Services & Networking
kubectl get svc
kubectl expose deployment web --port=80 --type=NodePort
kubectl get ingress
Config & Secrets
kubectl create configmap app-config --from-literal=env=prod
kubectl create secret generic db-secret --from-literal=user=admin
Storage
kubectl get pv
kubectl get pvc
kubectl get sc
Security (RBAC)
kubectl get roles --all-namespaces
kubectl get rolebindings --all-namespaces
kubectl get clusterroles
Logs & Debug
kubectl logs <pod>
kubectl exec -it <pod> -- /bin/sh
kubectl get events --sort-by=.metadata.creationTimestamp
Apply Workflow
kubectl apply -f app.yaml
kubectl delete -f app.yaml
kubectl diff -f app.yaml