☸️ Kubernetes Cheat Sheet 2025: YAML, CLI & Concepts From Beginner to Advanced
Kubernetes (K8s) is now the backbone of cloud-native infrastructure. Whether you’re deploying a simple app or running enterprise-scale microservices, knowing Kubernetes is no longer optional — it’s essential.
This cheat sheet is your one-stop guide — from basic YAML templates and kubectl commands to architecture, scaling, security, and beyond.
Let’s dive in. Bookmark this — you’ll use it often!

🔹 Section 1: What Is Kubernetes?
Kubernetes is an open-source container orchestration platform that helps manage:
- Deployments
- Scaling
- Networking
- Monitoring
- Self-healing of containerized applications
It runs workloads using Pods, manages traffic using Services, and scales using Controllers.
🧱 Section 2: Kubernetes Architecture – Key Components
Component | Description |
---|---|
Pod | Smallest deployable unit; contains one or more containers |
Node | A physical or virtual machine running pods |
Cluster | Set of worker nodes managed by the control plane |
Deployment | Manages stateless application versions and scaling |
Service | Provides stable networking to Pods |
Ingress | Routes external traffic to services via URL rules |
ConfigMap / Secret | Injects configuration or sensitive data into pods |
Namespace | Isolates resources in a multi-tenant cluster |
📄 Section 3: Common YAML Templates
✅ Pod
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: myapp
image: nginx
✅ Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: webapp
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx
✅ Service
apiVersion: v1
kind: Service
metadata:
name: web-service
spec:
type: NodePort
selector:
app: web
ports:
- port: 80
targetPort: 80
✅ Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
spec:
rules:
- host: app.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web-service
port:
number: 80
💻 Section 4: kubectl CLI – Cheat Sheet Commands
🔍 Get Information
kubectl get pods # List pods
kubectl get svc # List services
kubectl get nodes # List nodes
kubectl get deployments # List deployments
kubectl describe pod <pod> # Details of a pod
🛠 Manage Resources
kubectl apply -f app.yaml # Create or update resources
kubectl delete -f app.yaml # Delete resources
kubectl rollout restart deployment <name> # Restart a deployment
🚪 Logs & Debugging
kubectl logs <pod-name> # View logs
kubectl exec -it <pod> -- bash # Enter container shell
kubectl top pods # View resource usage
📦 Namespace Management
kubectl get ns # List namespaces
kubectl config set-context --current --namespace=my-namespace
📦 Section 5: Configs, Secrets & Environment
✅ ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
APP_MODE: "production"
✅ Secret
apiVersion: v1
kind: Secret
metadata:
name: db-secret
type: Opaque
data:
DB_PASSWORD: cGFzc3dvcmQ= # base64 encoded
✅ Use in Pod
envFrom:
- configMapRef:
name: app-config
- secretRef:
name: db-secret
🚀 Section 6: Scaling & Auto-Healing
Feature | Command |
---|---|
Manual Scaling | kubectl scale deployment webapp --replicas=5 |
Auto Scaling | Enable with HPA: kubectl autoscale deployment webapp --min=2 --max=10 --cpu-percent=80 |
Self-Healing | If a pod crashes, Kubernetes restarts it automatically |
🧠 Section 7: Advanced Concepts & Tools
Feature | Use Case |
---|---|
Helm | Package manager for Kubernetes apps (Charts) |
Kustomize | Manage environment-specific configs |
ArgoCD / Flux | GitOps-style continuous deployment |
HPA/VPA | Autoscale pods based on CPU, memory |
CRD | Extend Kubernetes API with custom resources |
Operators | Automate complex application management (e.g., DBs, queues) |
🔐 Section 8: Security & Best Practices
Feature | Purpose |
---|---|
RBAC | Control who can access what in the cluster |
Network Policies | Control pod-to-pod communication |
Pod Security | Limit privileged containers |
Secret Management | Encrypt sensitive data |
Admission Controllers | Validate/modify requests at runtime |
📊 Section 9: Observability – Logs, Metrics, Traces
Tool | Function |
---|---|
Prometheus | Collect metrics |
Grafana | Visualize data |
Loki | Centralize logs |
Jaeger | Trace requests |
ELK Stack | Log aggregation & search |
📚 Section 10: Learning & Certification Resources
Resource | Description |
---|---|
kubernetes.io/docs | Official documentation |
Play with Kubernetes | Interactive sandbox |
KodeKloud | Labs & CKA practice |
TechWorld with Nana | Best YouTube channel |
CKA Certification | Become a Certified K8s Admin |
🏁 Final Thoughts
Kubernetes may look complex at first, but this cheat sheet breaks it down into:
- 🧱 Architecture — Know what parts make the system
- 📄 YAML — Define your app’s desired state
- 💻 kubectl — Control the system with ease
- 🛡 Security & Observability — Production readiness
- 🚀 Advanced Tools — Helm, ArgoCD, CRDs, GitOps
Learn once. Practice often. Use everywhere.
Kubernetes is not just a trend — it’s the operating system of the cloud.
Leave a Reply