← all cheat sheets
OPERATOR REFERENCE · KUBERNETES

Kubernetes Field Reference
kubectl, Workloads & Debugging

context → get/describe → deploy → debug → services → config — one page, every day
kubectl · CLIENT
REST calls over TLS
API SERVER → ETCD / SCHEDULER / KUBELET
01 Cluster & Context

Contexts

kubectl config get-contexts kubectl config use-context prod

Cluster Info

kubectl cluster-info kubectl get nodes -o wide

Namespaces

kubectl get ns kubectl config set-context --current --namespace=staging
02 Core Resources — Get / Describe

Get

kubectl get pods -n app kubectl get svc,deploy,nodes kubectl get pods -o wide

Describe

kubectl describe pod web-7c9d-xk2
The Events section at the bottom is where scheduling/pull/crash reasons actually show up.
🏷

Labels & Selectors

kubectl get pods -l app=web kubectl label pod web-7c9d-xk2 tier=frontend
03 Deploying Workloads

Apply / Create

kubectl apply -f deployment.yaml kubectl create deployment web --image=nginx
apply is declarative (diff-and-reconcile); create is imperative and errors if it already exists.

Scale

kubectl scale deployment web --replicas=4 kubectl autoscale deployment web --min=2 --max=10 --cpu-percent=70

Rollouts

kubectl rollout status deployment/web kubectl rollout undo deployment/web kubectl rollout history deployment/web
04 Pods & Debugging
📄

Logs

kubectl logs web-7c9d-xk2 kubectl logs web-7c9d-xk2 -f kubectl logs web-7c9d-xk2 --previous
--previous shows the log of the crashed container instance, before the last restart.

Exec / Shell

kubectl exec -it web-7c9d-xk2 -- /bin/sh

Port-Forward / Copy

kubectl port-forward pod/web-7c9d-xk2 8080:80 kubectl cp web-7c9d-xk2:/var/log/app.log ./app.log
05 Services & Networking
🌐

Expose

kubectl expose deployment web --port=80 --target-port=8080

Service Types

  • ClusterIP — internal only, default
  • NodePort — exposes a static port on every node
  • LoadBalancer — cloud provider provisions an external LB

Endpoints

kubectl get endpoints web
Empty endpoints with a healthy-looking Service almost always means the label selector doesn't match any pod.
06 ConfigMaps & Secrets

ConfigMap

kubectl create configmap app-cfg --from-file=app.conf kubectl describe configmap app-cfg
🔒

Secret

kubectl create secret generic db-cred --from-literal=password=changeme
⚠ base64-encoded, not encrypted at rest by default — enable encryption at rest for real secrets
07 Common Errors & Quick Reference
SymptomLikely Cause
CrashLoopBackOffapp exits on start — check logs --previous
ImagePullBackOffwrong tag, private registry auth, or typo'd image name
Pendingno node has enough CPU/mem, or unmet nodeSelector/taint
OOMKilledcontainer exceeded its memory limit
Service has no trafficselector labels don't match pod labels
0/1 Readyreadiness probe failing — check the probe path/port
CommandPurpose
kubectl get events --sort-by=.lastTimestampdebug cluster-wide recent events
kubectl top podslive CPU/memory usage (needs metrics-server)
kubectl apply -f x.yaml --dry-run=clientsafe validate without applying
kubectl delete pod x --grace-period=0 --forcedestructive skip graceful termination
kubectl explain pod.spec.containersinline field documentation
kubectl get pod x -o yamlfull resource definition as applied