βΈοΈ Kubernetes Cheatsheet
A compact guide to Kubernetes architecture, tools, kubectl commands, pod management, and exam resources.
ποΈ Architectural Overview
π§ Control Plane Node
kube-api-serverkube-schedulerkube-controller-manageretcd
π οΈ Worker Node
kubeletcontainer runtime(external to Kubernetes)kube-proxy
π§° Tools
kubectlβ CLI for Kuberneteskubeadmβ Cluster creationminikubeβ Local dev clusterhelmβ Package managerkomposeβ Docker to K8s converterkustomizeβ Configuration management
π§ͺ kubectl Commands
π Namespaces
kubectl get namespaces
kubectl create namespace myspace
kubectl get pods --namespace myspace
kubectl get pods -n kube-system
kubectl delete namespace my-namespace
π Context
kubectl config view
kubectl config get-contexts
kubectl config set-context --current --namespace=awx
kubectl config current-context
β‘ Imperative Commands
kubectl create deployment my-deployment --image=nginx
kubectl create deployment my-deployment --image=nginx --dry-run -o yaml
kubectl create sa my-service-account -n myspace
kubectl scale deployment my-deployment replicas=5 --record
π¦ Object Management
π API Resources
π₯ Get Objects
kubectl get pod -h
kubectl get <type> <name> -o <output> --sort-by <jsonPath> --selector <selector>
kubectl get nodes -o wide
kubectl get pods -n awx
kubectl get pods -n awx --selector app.kubernetes.io/component=database
kubectl get pods -n awx --sort-by .status.hostIP
kubectl get pv --sort-by .spec.capacity.storage
π Describe Objects
π Logs
kubectl logs logtest
kubectl logs logtest --container syncer
kubectl logs -f -l app=nginx --all-containers=true
kubectl logs -l app=nginx --all-containers=true
𧨠Exec into Pod
kubectl exec hello-pod -- ps
kubectl exec -it hello-pod -- sh
kubectl exec test-pod -- curl localhost:8080
𧬠Pods Deep Dive
Pod Features
- Resource Sharing
- Advanced Scheduling
- Health Probes
- Restart Policies
- Security Policies
- Termination Control
- Volumes