SadServers
  • Scenarios
  • Labs
    All Labs Linux & Bash Web Servers Databases Data Processing Docker Kubernetes CI/CD Infrastructure as Code Tooling / Applications
  • Dashboard
  • Solutions
    For Individuals For Businesses
  • Ranking
  • Newsletter
  • Documentation
    FAQ Support Pro Accounts Pro+ Accounts Business Accounts Gift API CLI/TUI Privacy Troubleshooting Interviews
  • Blog
  • Pricing
  • Gift
    Gift Purchase Gift Redeem
  • About
Log In - Sign Up
  1. Labs
  2. Kubernetes
  3. Cheatsheet

Guide

Concepts and learning path

Troubleshooting

Failure modes and fixes

Cheatsheet

Commands to keep handy

Kubernetes cheatsheet

Context and namespace

CommandDescription
kubectl config get-contextsList contexts
kubectl config use-context NAMESwitch cluster
kubectl config set-context --current --namespace=nsDefault namespace
kubectl get nsList namespaces

Get and describe

CommandDescription
kubectl get pods -AAll pods, all namespaces
kubectl get pods,svc,deploy -n appMultiple resource types
kubectl get pods -o wideNode, IP, status
kubectl describe pod POD -n appEvents, conditions, mounts
kubectl get events -n app --sort-by=.lastTimestampRecent events

Logs and exec

CommandDescription
kubectl logs POD -n app -fFollow pod logs
kubectl logs POD -c CONTAINER -n appSpecific container
kubectl logs POD --previous -n appLogs from crashed container
kubectl exec -it POD -n app -- shShell in running pod

Apply, scale, rollout

CommandDescription
kubectl apply -f manifest.yamlCreate or update resources
kubectl delete -f manifest.yamlDelete from manifest
kubectl scale deploy/APP --replicas=3 -n appScale deployment
kubectl rollout status deploy/APP -n appWait for rollout
kubectl rollout undo deploy/APP -n appRollback deployment

Debugging

kubectl run tmp --rm -it --image=busybox -- sh kubectl debug -it POD -n app --image=busybox --target=CONTAINER kubectl port-forward svc/myapp 8080:80 -n app kubectl top pods -n app kubectl top nodes

krew — install and common plugins

# Install krew: https://krew.sigs.k8s.io/docs/user-guide/setup/install/ kubectl krew install stern ctx ns tree view-secret neat popeye # stern — multi-pod log tail (essential for debugging) stern . -n app # all pods in namespace stern -l app=web -n app -c nginx # by label, one container stern POD_PREFIX -n app --since 5m # recent logs only # ctx / ns — fast context and namespace switch (kubectx / kubens) kubectl ctx # list contexts kubectl ctx prod-cluster kubectl ns app # tree — resource hierarchy kubectl tree deploy/myapp -n app # view-secret — decode secrets on CLI kubectl view-secret secret/mysecret -n app # neat — cleaner YAML output (remove managed fields noise) kubectl get deploy myapp -o yaml | kubectl neat # popeye — cluster hygiene report kubectl popeye -n app

Other helpful CLIs

ToolDescription
k9sTerminal UI for cluster navigation
helmChart installs — see Helm lab
kubectl debugEphemeral debug containers (built-in)

Cluster health

CommandDescription
kubectl get nodesNode Ready status
kubectl get componentstatusesDeprecated; use node/control-plane checks
kubectl cluster-infoAPI server and kube-dns addresses
kubectl auth can-i create pods -n appRBAC check

Pro tips

  • kubectl describe Events section explains most pod failures
  • --previous logs show why the last container crashed
  • Install stern via krew — faster than looping kubectl logs
  • Always set -n NAMESPACE — wrong namespace is a common mistake
  • Helm releases: use the Helm lab, not raw YAML guesswork

Practice scenarios

Hands-on Kubernetes scenarios on live Linux VMs: kubernetes

SadServersSadServers

Real-world Linux and DevOps scenarios for hands-on learning and technical assessment.

Uptime Robot ratio (30 days)
Product
  • Scenarios
  • For Individuals
  • For Businesses
  • Pricing
Resources
  • FAQ
  • Blog
  • Newsletter
Company
  • About Us
  • Support
  • Privacy Policy
  • Terms of Service
  • Contact
Connect With Us
info@sadservers.com

Made in Canada 🇨🇦
Updated: 2026-06-13 16:06 UTC – 2d2950a