Kubectl Cheatsheet

Last updated: April 2025

🔍 Cluster connection

kubectl config use-context my-cluster

📦 Work with pods

kubectl get pods -A
kubectl describe pod my-pod
kubectl exec -it my-pod -- /bin/bash
    

💾 Storage

kubectl get pvc
kubectl apply -f pv-pvc.yaml
    

📄 Useful YAML Manifests

📥 Download

You can download a helpful visual flowchart for Kubernetes troubleshooting:
Download: Troubleshooting Flowchart (PDF)

🔧 Kubernetes Command Map

Kubernetes Command Map ((This guide has been compiled through numerous experiences to help avoid confusion.))

1. 🔧 Pod Management
kubectl get pods — Your first response to "why isn't my app running?"

kubectl describe pod  — Deep dive into pod issues (check events section first)

kubectl logs  — App throwing errors? Start here

kubectl exec -it  -- /bin/bash — Investigate from inside

2. 🖥️ Cluster Management
kubectl get nodes — Quick cluster health check

kubectl get pods — Checking application instances

kubectl get svc — Understanding service endpoints

kubectl version — Checking Kubernetes components

3. 🌐 Service Management
kubectl get services — Track your exposed endpoints

kubectl expose deployment — Making your app accessible

kubectl port-forward — Quick local testing without ingress

kubectl describe service  — Inspect service details

4. 📊 Resource Monitoring
kubectl top pods — Find memory leaks and CPU spikes

kubectl get events — Your incident investigation starting point

kubectl describe events — Detailed timeline of what went wrong

kubectl top nodes — Monitoring node resource usage

5. 🗂️ Namespace Management
kubectl create namespace — Start clean, stay organized

kubectl get namespaces — Lost a resource? Check all namespaces

kubectl config set-context — Switch contexts without confusion

kubectl delete namespace — The nuclear option (use carefully!)

6. 🚀 Deployment Management
kubectl create deployment — Launch your app

kubectl rollout status — Is the new version rolling out?

kubectl scale deployment — Handle that traffic spike

kubectl rollout undo — Quick revert when things go wrong

7. 🔐 Configuration & Secrets
kubectl create configmap — External config done right

kubectl create secret — Keep those credentials safe

kubectl get configmaps — What's my app's config?

kubectl get secrets — Audit your secret management
	
← Back to main page