๐Ÿ“„ Kubernetes Command Cheat Sheet - Reader

A clean and practical reference for managing and troubleshooting Kubernetes clusters.
These are the commands I use most often.

๐Ÿ“ฆ Pods (Inspect, Logs, Exec, Manage)

๐Ÿ” List & Inspect Pods

kubectl get pods
kubectl get pods -n <namespace>
kubectl get pods --all-namespaces
kubectl describe pod <pod-name>

Pods on a specific node

kubectl get pods -A -o wide | grep <node>

Pod resource requests

kubectl get pods -n <ns> -o json | jq -r '.items[] |
  "\(.metadata.name)\tCPU:\(.spec.containers[0].resources.requests.cpu)\tMEM:\(.spec.containers[0].resources.requests.memory)"'

Pod tolerations

kubectl get pods -n <ns> -o json | jq -r '.items[] |
  "\(.metadata.name)\t\(.spec.tolerations | map(.key) | join(","))"'

Pod events

kubectl describe pod <pod> -n <ns> | grep -A 10 "Events:"

Pod resource usage (metrics-server)

kubectl top pods -n <ns>

๐Ÿชต Logs

kubectl logs <pod>
kubectl logs <pod> -c <container>
kubectl logs -f <pod>
kubectl logs -l app=<label>

one-liner sample to load with a key-word

kubectl logs -n name_space "$(kubectl get pods -n name_space --no-headers | awk '/prod/ {print $1; exit}')"

๐Ÿ’ป Exec / Shell Access

kubectl exec -it <pod> -- /bin/bash
kubectl exec -it <pod> -- /bin/sh
kubectl exec -it <pod> -c <container> -- /bin/bash

๐Ÿงน Pod Management

kubectl delete pod <pod> -n <ns>
kubectl delete pod <pod> -n <ns> --force --grace-period=0
kubectl delete pod --all -n <ns>
kubectl delete pod -n <ns> -l key=value

๐ŸŒ Services

kubectl get services
kubectl get services -n <namespace>
kubectl get services --all-namespaces

๐Ÿง  Nodes (Inspect, Usage, Manage)

๐Ÿ” Node Info

kubectl get nodes
kubectl get nodes -o wide
kubectl describe node <node>

Node labels, taints, instance type

kubectl get node <node> -o json | jq '.metadata.labels'
kubectl describe node <node> | grep Taints
kubectl get node <node> -o json | jq -r '.metadata.labels."node.kubernetes.io/instance-type"'

๐Ÿ“Š Node Resource Usage

kubectl describe node <node> | grep -A 5 "Allocated resources"
kubectl top nodes

๐Ÿ›  Node Management (Cordon / Drain / Delete)

๐Ÿ”น Cordon โ€” stop scheduling new pods

kubectl cordon <node>

๐Ÿ”น Drain โ€” evict workloads safely

kubectl drain <node> --ignore-daemonsets --delete-emptydir-data --force

๐Ÿ”น Delete โ€” remove node from Kubernetes

kubectl delete node <node> --force --grace-period=0

๐Ÿ“˜ Quick Comparison

Action Stops New Pods? Evicts Pods? Removes Node? Use Case
cordon โœ”๏ธ โŒ โŒ Prepare for maintenance
drain โœ”๏ธ โœ”๏ธ โŒ Safely remove workloads
delete โœ”๏ธ โœ”๏ธ (node gone) โœ”๏ธ Node is broken or gone

๐Ÿงฑ Storage (PVC)

List PVCs

kubectl get pvc -A
kubectl get pvc -n <namespace>

Describe a PVC

kubectl describe pvc <pvc-name> -n <namespace>

Check volume affinity issues

kubectl describe pod <pod> -n <ns> | grep -i volume

โ›‘ Pod Disruption Budgets (PDB)

kubectl get pdb -A
kubectl get pdb -n <namespace>
kubectl describe pdb <pdb> -n <namespace>

๐Ÿ”ง Useful Commands

Count pods on a node

kubectl get pods -A -o wide | grep <node> | wc -l

Count pods by namespace

kubectl get pods -A --no-headers | awk '{print $1}' | sort | uniq -c

List instance types in the cluster

kubectl get nodes -o json | jq -r \
'.items[].metadata.labels."node.kubernetes.io/instance-type"' | sort | uniq

Node โ†’ workload mapping

kubectl get nodes -o json | jq -r '.items[] |
  "\(.metadata.name)\t\(.metadata.labels.workload // "none")\t\(.metadata.labels."node.kubernetes.io/instance-type")"'

Keep reading

More in Engineering

  1. Engineering Fundamentals for Agent Programming

    ยท 4 min read

    What I set up so agents can write all my code and I can review less: a clean codebase, real verification, written-down domain knowledge, and auto-merge for the PRs that earn it.

  2. AI Coding: Programming by Coincidence at Scale

    ยท 2 min read

    AI lets us pile up code we don't understand faster than ever. Working code is not correct code.

  3. Keycloak Components: Roles, Scopes, Client Scopes, and Audience

    ยท 8 min read

    AI-researched

    A simple explanation of how Keycloak controls access from an app to an SSH MCP server.

  4. Attention has four matrices, not three

    ยท 13 min read

    AI-researched

    Q, K, V, and the output projection the name leaves out. What each weight does to the same input, and why the differences between them decide what an inference server has to cache.

๐Ÿ“‚ All 14 posts in Engineering