Kubernetes Orchestration Quick Reference

Kubernetes (kubectl), Pods, Deployments & Services Cheat Sheet

Kubernetes schedules your containers into Pods across worker machines, keeps the desired replica count healthy via Deployments, and exposes them reliably using Servicesโ€”all controlled through the kubectl CLI.

โฑ๏ธ 9 min reference๐ŸŸข Beginner Friendly๐Ÿ“… Updated: 2026

Anatomy of a kubectl Command

kubectl get pods -n prod -o wide
CLI Tool kubectl Talks to the K8s API Server
Action (Verb) get What to do (get, describe, delete)
Resource Type pods Object (po, deploy, svc, ns)
Flags / Scope -n prod -o wide Namespace & extra columns
Kubernetes Architecture: Control Plane, Nodes, Pods & Service API Server โ†’ Nodes โ†’ Pods
kubectl Admin CLI CONTROL PLANE kube-apiserver Scheduler + etcd Controller Mgr WORKER NODE 1 (kubelet) Pod A Pod B WORKER NODE 2 (kubelet) Pod C kube-proxy SERVICE Stable IP & DNS Load balances traffic to Pods

1 Core Kubernetes Objects

Everything in Kubernetes is an API object defined in YAML. Here are the 8 building blocks you will touch every day.

Object Short Name What It Does (Plain English)
Pod po Smallest deployable unit; wraps 1+ tightly coupled containers sharing an IP and volumes.
Deployment deploy Manages stateless Pods: handles rolling updates, scaling replicas, and rollbacks.
ReplicaSet rs Ensures a fixed number of identical Pod copies stay running (managed by Deployment).
Service svc Provides a stable virtual IP & DNS name that load-balances across ephemeral Pods.
ConfigMap cm Stores non-sensitive configuration (env vars, config files) separate from images.
Secret secret Stores sensitive values (passwords, API keys, TLS certs) mounted as env vars or files.
Ingress ing HTTP/HTTPS router that maps external domains/paths (/api) to Services.
Namespace ns Virtual cluster partition (e.g., dev, staging, prod) for isolation.

2 kubectl Inspection & Debugging

When a Pod refuses to start or crashes, follow the golden triage loop: get โ†’ describe โ†’ logs โ†’ exec.

kubectl get pods -A -o wide
List Pods Across All Namespaces -A shows all namespaces; -o wide reveals the Pod IP and which Worker Node it runs on.
kubectl describe pod <pod> -n <ns>
Inspect Pod Spec & Events Scroll to the bottom Events section to diagnose ImagePullBackOff, failed probes, or scheduling blocks.
kubectl logs -f --previous <pod>
Check Logs of a Crashed Container --previous grabs logs from the container instance that just crashed in CrashLoopBackOff. Drop --previous for live logs.
kubectl exec -it <pod> -- sh
Open an Interactive Shell Inside a Pod Use -- to separate kubectl flags from the container command (sh or bash).
kubectl top pods --sort-by=memory
View Real-Time CPU & Memory Usage Requires Metrics Server. Quickly spots memory leaks before an OOMKilled crash.
kubectl get events --sort-by='.metadata.creationTimestamp'
Stream Cluster Events Chronologically Surfaces node pressure, volume mount errors, and eviction warnings in order.

3 Services & Networking

Pod IPs change every time a Pod restarts. A Service gives your Pods a permanent internal DNS name (<service>.<namespace>.svc.cluster.local) and routes traffic by label selector.

Service Type Who Can Reach It? Typical Use Case
ClusterIP (default) Only Pods inside the cluster. Internal APIs, Redis, PostgreSQL databases.
NodePort External traffic via <NodeIP>:30000โ€“32767. Local clusters (Minikube/kind) or custom external LBs.
LoadBalancer Public internet via cloud LB (AWS ELB, GCP LB). Production web apps or Ingress Controllers.
kubectl port-forward svc/<svc> 8080:80
Tunnel a ClusterIP Service to Localhost Safely access an internal Service or Pod on http://localhost:8080 without exposing it publicly.
kubectl get svc,ep -n <ns>
Verify Service & Ready Pod Endpoints If ENDPOINTS is <none>, your Service selector labels don't match your Pod labels.

4 Deployments, Scaling & Rollbacks

Never create bare Pods in productionโ€”always wrap them in a Deployment so Kubernetes can replace failed Pods and perform zero-downtime rolling updates.

Memory Trick โ€” The Declarative Loop: Edit YAML โ†’ apply -f โ†’ watch rollout status โ†’ if broken, hit rollout undo. You never manually delete old Pods during a release; the Deployment controller swaps them gradually.
kubectl apply -f deployment.yaml
Create or Update Resources Declaratively Applies YAML changes to the cluster. Safe and idempotent to run repeatedly.
kubectl scale deploy/<name> --replicas=5
Scale Pod Replicas Up or Down Immediately adjusts the desired Pod count (update your YAML too so Git stays in sync).
kubectl rollout status deploy/<name>
Watch Rolling Update Progress Blocks until all new Pods pass readiness probes and old Pods terminate.
kubectl rollout undo deploy/<name>
Instant Rollback to Previous Revision Reverts a bad release back to the last working ReplicaSet in seconds.

5 Danger Zone & Beginner Traps

โš ๏ธ Watch Out Before You Hit Enter
1. kubectl delete ns <namespace> Wipes Everything Inside

Deleting a Namespace cascades and immediately destroys every Pod, Deployment, Service, Secret, ConfigMap, and PersistentVolumeClaim inside it. Always double-check the namespace name.

2. Missing CPU/Memory requests & limits

Without resource requests and limits in your Pod spec, one runaway container can starve an entire Worker Node and trigger cluster-wide OOMKilled evictions.

3. Seeing CrashLoopBackOff Without Checking --previous Logs

Running plain kubectl logs <pod> on a restarting Pod often returns an empty or half-booted log. Always add --previous to see the actual error that killed the last container.

4. Running Commands Against the Wrong Cluster Context

If you switch between minikube, staging, and prod, verify your target first with kubectl config current-context before running apply or delete.