Kubernetes Cheatsheet
Core kubectl commands to inspect, deploy, and debug workloads in minutes.
Contexts & Namespaces
| Key / Code | Description |
|---|---|
| kubectl config get-contexts | List contexts. |
| kubectl config use-context <ctx> | Switch context. |
| kubectl config set-context --current --namespace=dev | Set default namespace. |
Workloads
| Key / Code | Description |
|---|---|
| kubectl get pods | List pods. |
| kubectl get deploy | List deployments. |
| kubectl apply -f app.yaml | Apply manifest. |
| kubectl rollout status deploy/app | Check rollout status. |
| kubectl scale deploy/app --replicas=3 | Scale replicas. |
Services & Ingress
| Key / Code | Description |
|---|---|
| kubectl get svc | List services. |
| kubectl describe svc api | Describe a service. |
| kubectl get ingress | List ingresses. |
Config & Secrets
| Key / Code | Description |
|---|---|
| kubectl get configmap | List ConfigMaps. |
| kubectl create configmap app-config --from-file=./config | Create a ConfigMap. |
| kubectl get secret | List Secrets. |
Debugging
When things fail, focus on status, logs, and events.
kubectl describe pod <pod>
kubectl logs <pod>
kubectl logs <pod> -c <container>
kubectl get events --sort-by=.metadata.creationTimestampKnowledge is power.