Most engineers know kubectl get pods and kubectl describe. But kubectl has some incredibly powerful features hiding in plain sight.
1. kubectl get with custom columns
Stop piping to awk and cut. Custom columns give you exactly the output you need:
kubectl get pods -o custom-columns=\
NAME:.metadata.name,\
STATUS:.status.phase,\
CPU:.spec.containers[0].resources.requests.cpu,\
RESTARTS:.status.containerStatuses[0].restartCount
This outputs a clean table with only the fields you care about. You can reference any field in the pod spec using JSONPath.
2. kubectl diff
Preview changes before applying them:
kubectl diff -f deployment.yaml
This shows exactly what will change in your cluster, formatted like a git diff. Essential for production deployments where surprises are expensive.
3. kubectl debug
Attach a debugging container to a running pod without modifying its spec:
kubectl debug -it my-pod --image=busybox --target=my-container
This creates an ephemeral container that shares the process namespace with your target container. You get access to the filesystem, network, and processes without restarting anything.
4. kubectl top with sorting
Monitor resource usage across pods with sorting:
kubectl top pods --sort-by=cpu -n production
kubectl top nodes --sort-by=memory
Quickly identify which pods are consuming the most resources. Requires the metrics-server to be installed in your cluster.
5. kubectl events with field selectors
Filter cluster events to find what you're looking for:
kubectl get events --field-selector reason=Failed -n production
kubectl get events --sort-by='.lastTimestamp' -n production | tail -20
Events are the first thing to check when something goes wrong. Field selectors let you cut through the noise instantly.
Bonus: aliases that save hours
Add these to your .bashrc or .zshrc:
alias k="kubectl"
alias kgp="kubectl get pods"
alias kgs="kubectl get svc"
alias kd="kubectl describe"
alias kl="kubectl logs -f"
alias kex="kubectl exec -it"
The best kubectl users aren't the ones who memorize every flag — they're the ones who know which tools and shortcuts to reach for at the right moment.