Ready for approval 2026/02/27 19:57 by zhein | Approver: @ai-us-principals
kubectl Cheat Sheet
CLUSTER LIFECYCLE COMMANDS
minikube start
minikube stop
minikube delete
Completely deletes the Kubernetes cluster
Removes all namespaces, system pods, and workloads
This is the correct way to fully reset Kubernetes
BASIC CLUSTER VERIFICATION
kubectl get nodes
kubectl get pods
kubectl get pods -A
RESOURCE INSPECTION
kubectl describe pod
Shows detailed pod configuration and runtime state
Displays events (very important for debugging)
First command to use when something is broken
WINDOWS CMD SHORTCUT
doskey k=kubectl $*
Creates a temporary shortcut so “k” can be used instead of “kubectl”
Only lasts for the current Command Prompt session
Windows CMD does not support Linux-style aliases
kubectl get pods
kubectl get pods -o wide
kubectl get pod -o yaml
kubectl get pods -o name
kubectl get pods -o custom-columns=NAME:.metadata.name,PHASE:.status.phase
kubectl get pods -o jsonpath=“{.items[*].metadata.name}“
IMPERATIVE VS DECLARATIVE
DEBUGGING PODS AND CONTAINERS
Standard debugging flow:
1. kubectl get pods → Identify failing or pending pods
2. kubectl describe pod → Look at events and status
3. kubectl logs → View application logs
4. kubectl logs –previous → View logs from a crashed container
5. kubectl exec -it – sh → Access a running container shell
6. kubectl debug -it –image=busybox –target=[PODNAME] → Attach an ephemeral debug container
Important distinction:
NAMESPACES AND CONTEXTS
kubectl create namespace sandbox
kubectl get pods -n sandbox
kubectl config set-context –current –namespace=sandbox
kubectl config current-context
Namespaces are the safest unit for testing and cleanup.
CLEANUP COMMANDS
KUBE-SYSTEM NAMESPACE
Created automatically by Kubernetes
Contains control plane and core system components
Cannot and should not be deleted
A clean cluster always includes kube-system pods
If you want kube-system gone, delete the entire cluster instead.
WINDOWS-SPECIFIC NOTES
Windows CMD does not support alias; use doskey
YAML editing is done with external editors (Notepad, VS Code)
JSONPath requires double quotes in CMD
Many Kubernetes tutorials assume Linux shells and need adjustment
COMMON MISTAKES AND GOTCHAS
Thinking kubectl installs or runs Kubernetes
Expecting an empty cluster after cleanup
Trying to delete kube-system
Forgetting namespaces when resources seem missing
Confusing pod names with container names
Using imperative commands for long-term management
Assuming Linux shell commands work on Windows CMD
Editing live resources instead of source YAML
MENTAL MODELS
kube-system = operating system processes
Your namespaces = application folders
kubectl delete deployment = uninstalling an app
minikube delete = reinstalling the
OS
AI Home