Your go-to cheat sheet for Kubernetes interviews and daily work
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β KUBERNETES CLUSTER β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββββββββββ ββββββββββββββββββββββββ β
β β CONTROL PLANE β β WORKER NODES β β
β β (Managed by Cloud) β β (VMs/Bare Metal) β β
β β β β β β
β β β’ API Server β β βββββββββββββββ β β
β β β’ etcd (Storage) βββββββΊβ β NODE 1 β β β
β β β’ Scheduler β β β β β β
β β β’ Controller Mgr β β β Pod1 Pod2 β β β
β ββββββββββββββββββββββββ β β Pod3 Pod4 β β β
β β β β β β
β β β + kubelet β β β
β β β + kube-proxyβ β β
β β βββββββββββββββ β β
β β β β
β β βββββββββββββββ β β
β β β NODE 2 β β β
β β β (more pods)β β β
β β βββββββββββββββ β β
β ββββββββββββββββββββββββ β
β β
β Flow: Cluster β Nodes (VMs) β Pods (Containers) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Remember this hierarchy:
Kubernetes Cluster
βββ Nodes (Virtual Machines or Bare Metal)
βββ Pods (Smallest deployable unit)
βββ Containers (Your application)
# Quick Setup
eksctl create cluster --name my-cluster --region us-east-1| Feature | Details |
|---|---|
| Load Balancer | ALB (Application), NLB (Network) |
| Storage | EBS (Block), EFS (File System) |
| Authentication | IAM Roles & Policies |
| Networking | VPC CNI Plugin |
| Best For | Already using AWS services, tight AWS integration |
π‘ Quick Answer: "EKS is AWS's managed Kubernetes with deep integration into AWS services like IAM, EBS, and VPC."
# Quick Setup
az aks create --resource-group myRG --name myCluster --node-count 3| Feature | Details |
|---|---|
| Load Balancer | Azure Load Balancer |
| Storage | Azure Disks, Azure Files |
| Authentication | Azure Active Directory |
| Networking | Azure CNI, Kubenet |
| Best For | Microsoft ecosystem, best free tier, Windows containers |
π‘ Quick Answer: "AKS integrates with Azure AD and Azure services, offers the best free tier among the three."
# Quick Setup
gcloud container clusters create my-cluster --zone us-central1-a| Feature | Details |
|---|---|
| Load Balancer | Cloud Load Balancing |
| Storage | Persistent Disks, Filestore |
| Authentication | Google IAM |
| Networking | VPC-native, GKE networking |
| Best For | Easiest to use, Google services, best autopilot mode |
π‘ Quick Answer: "GKE is the easiest Kubernetes service, invented by Google (who created K8s), with excellent autopilot mode."
| Feature | AWS EKS | Azure AKS | GCP GKE |
|---|---|---|---|
| Ease of Use | βββ | ββββ | βββββ |
| Free Tier | β ($0.10/hr) | β Best | β Good |
| Autopilot | β | β | β Best |
| Market Share | π₯ Largest | π₯ Second | π₯ Third |
| Best Use | AWS ecosystem | Microsoft stack | Beginners, GCP users |
π― Interview Answer Template:
"All three provide managed Kubernetes with identical core components. EKS for AWS integration, AKS for Azure/Microsoft with best free tier, GKE for easiest setup and best autopilot mode. The choice depends on your existing cloud ecosystem."
| Type | Size | Startup Time | Cost | Isolation | Use Case |
|---|---|---|---|---|---|
| Virtual Machine | GBs | Minutes | π°π°π° | βββββ | Legacy apps, OS control |
| Container | MBs | Seconds | π° | βββ | Microservices, modern apps |
| Bare Metal | - | Hours | π°π°π°π° | βββββ | HPC, databases |
| Serverless | - | Milliseconds | π° (pay-per-use) | ββββ | Event-driven, sporadic |
β
Pros:
β’ Strong isolation (separate OS kernel)
β’ Full OS-level control
β’ Better for legacy applications
β’ Can run different OS on same hardware
β Cons:
β’ Heavy (GBs in size)
β’ Slow startup (3-5 minutes)
β’ Resource intensive
β’ More expensive to run
π― Use When: Security-critical apps, stateful services, need OS isolation
β
Pros:
β’ Lightweight (MBs in size)
β’ Fast startup (seconds)
β’ Portable across environments
β’ Cost-effective
β’ Perfect for microservices
β Cons:
β’ Shared kernel (less isolation than VMs)
β’ Must use same OS as host
β’ Potential security concerns
π― Use When: Microservices, stateless apps, CI/CD, need agility
β
Pros:
β’ Maximum performance
β’ No virtualization overhead
β’ Direct hardware access
β Cons:
β’ Expensive
β’ Harder to manage
β’ Less flexible
π― Use When: High-performance computing, large databases, gaming servers
β
Pros:
β’ No node management
β’ Pay only for actual usage
β’ Auto-scaling built-in
β Cons:
β’ Limited control
β’ Cold start latency
β’ Vendor lock-in
π― Use When: Event-driven workloads, sporadic traffic, want zero ops
π― Interview Answer:
"Kubernetes typically runs on VMs for a balance of isolation and efficiency. Containers are lightweight and portable, while VMs provide stronger isolation. Bare metal is for performance-critical workloads like databases, and serverless (Fargate/Cloud Run) removes infrastructure management entirely."
| Component | Purpose | Analogy |
|---|---|---|
| API Server | Entry point for all commands | Reception desk |
| etcd | Stores cluster state & config | Database |
| Scheduler | Assigns pods to nodes | Traffic controller |
| Controller Manager | Maintains desired state | Thermostat |
| Component | Purpose | Analogy |
|---|---|---|
| kubelet | Agent on each node | Site manager |
| kube-proxy | Network routing | Switchboard |
| Container Runtime | Runs containers (Docker/containerd) | Engine |
π¦ Pod
ββ Smallest unit, wraps 1+ containers
ββ Example: nginx pod with 1 container
π Deployment
ββ Manages pod replicas and rolling updates
ββ Example: Web app with 3 replicas
π Service
ββ Exposes pods to network
ββ Types: ClusterIP, NodePort, LoadBalancer
ββ Example: LoadBalancer for external traffic
βοΈ ConfigMap
ββ Non-sensitive configuration data
ββ Example: Database connection strings
π Secret
ββ Sensitive data (base64 encoded)
ββ Example: API keys, passwords
πͺ Ingress
ββ HTTP/HTTPS routing rules
ββ Example: Route /api β backend, /web β frontend
πΎ PersistentVolume (PV) / PersistentVolumeClaim (PVC)
ββ Storage that survives pod restarts
ββ Example: Database data volume
π Namespace
ββ Virtual cluster for resource isolation
ββ Example: dev, staging, prod
Need to deploy an app?
βββΊ Use: Deployment + Service
Need external access?
βββΊ Use: Service (type: LoadBalancer) or Ingress
Need to store data permanently?
βββΊ Use: PersistentVolumeClaim (PVC)
Need configuration?
βββΊ Non-sensitive? β ConfigMap
βββΊ Sensitive? β Secret
Need to separate environments?
βββΊ Use: Namespaces (dev, staging, prod)
Need auto-scaling?
βββΊ Enable: HPA (Horizontal Pod Autoscaler)
Need to run background jobs?
βββΊ One-time job? β Job
βββΊ Recurring job? β CronJob
# List all nodes
kubectl get nodes
# List all pods in all namespaces
kubectl get pods -A
# List deployments
kubectl get deployments
# Get detailed info about a pod
kubectl describe pod <pod-name>
# Watch pods in real-time
kubectl get pods -w# Apply configuration
kubectl apply -f deployment.yaml
# Scale deployment
kubectl scale deployment <name> --replicas=5
# Check rollout status
kubectl rollout status deployment/<name>
# Rollback to previous version
kubectl rollout undo deployment/<name>
# Delete deployment
kubectl delete deployment <name># View pod logs
kubectl logs <pod-name>
# Follow logs (live)
kubectl logs -f <pod-name>
# Shell into a pod
kubectl exec -it <pod-name> -- /bin/bash
# View cluster events
kubectl get events
# Check resource usage
kubectl top nodes
kubectl top pods# Create a deployment imperatively
kubectl create deployment nginx --image=nginx --replicas=3
# Expose deployment as service
kubectl expose deployment nginx --port=80 --type=LoadBalancer
# Create namespace
kubectl create namespace devapiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-app
labels:
app: nginx
spec:
replicas: 3 # Number of pods
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.21
ports:
- containerPort: 80
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: LoadBalancer # External access
selector:
app: nginx # Matches deployment labels
ports:
- port: 80 # External port
targetPort: 80 # Container portapiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
database_url: "postgres://db:5432"
log_level: "info"apiVersion: v1
kind: Secret
metadata:
name: app-secrets
type: Opaque
data:
api_key: YXBpLWtleS0xMjM0NTY= # base64 encoded
db_password: cGFzc3dvcmQxMjM= # base64 encodedAnswer:
"Kubernetes has a control plane that manages the clusterβit includes the API server (entry point), etcd (stores state), scheduler (assigns pods), and controller manager (maintains desired state). Worker nodes run the actual workloads as pods. Pods contain one or more containers and are the smallest deployable units. The kubelet agent on each node communicates with the control plane."
Answer:
"A Pod is a single instance of containers. A Deployment manages multiple pod replicas, handles rolling updates, and maintains desired state. A Service provides stable networking to access pods, as pod IPs change when they restart."
Answer:
"Three types: HPA (Horizontal Pod Autoscaler) scales pods based on CPU/memory metrics. VPA (Vertical Pod Autoscaler) adjusts resource limits. Cluster Autoscaler adds or removes nodes. You define target metrics and min/max replicas, and K8s handles the rest."
Answer:
"ClusterIP (default) - internal cluster access only. NodePort - exposes service on each node's IP at a static port. LoadBalancer - provisions cloud load balancer for external access. ExternalName - maps service to external DNS name."
Answer:
# Step 1: Check pod status
kubectl get pods
# Step 2: Describe pod for events
kubectl describe pod <pod-name>
# Step 3: Check logs
kubectl logs <pod-name>
# Step 4: Check previous logs if crashed
kubectl logs <pod-name> --previous
# Step 5: Shell into pod if running
kubectl exec -it <pod-name> -- /bin/bashAnswer:
"ConfigMap stores non-sensitive configuration like database URLs, feature flags. Secret stores sensitive data like passwords, API keys, and is base64 encoded (not encrypted by defaultβuse encryption at rest for production)."
Answer:
"Deployment is for stateless appsβpods are interchangeable. StatefulSet is for stateful apps like databasesβpods have stable network IDs, persistent storage, and ordered deployment/scaling."
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: nginx-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx-app
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80# Enable HPA via command
kubectl autoscale deployment nginx-app --cpu-percent=80 --min=2 --max=10- Cluster β Nodes β Pods β Containers (hierarchy)
- Nodes are typically VMs, but can be bare metal or serverless
- Pods are ephemeral - they can die and restart anytime
- Services provide stable networking to pods
- Deployments manage pod lifecycle and rolling updates
- All three clouds (EKS/AKS/GKE) use the same core K8s components
- YAML is declarative - you describe desired state, K8s makes it happen
- Namespaces provide logical isolation within a cluster
- ConfigMaps for config, Secrets for sensitive data
- HPA scales horizontally (more pods), VPA scales vertically (more resources)
βοΈ Networking
βββ VPC (Virtual Private Cloud)
βββ Subnets (public/private)
βββ Security Groups / Firewall Rules
βββ Load Balancers
πΎ Storage
βββ Persistent Volumes (EBS, Azure Disks, GCP PD)
βββ File Storage (EFS, Azure Files, Filestore)
βββ Object Storage (S3, Blob, GCS)
π₯οΈ Compute
βββ Worker Nodes (EC2, Azure VMs, GCE instances)
βββ Control Plane (managed by cloud provider)
βββ Container Registry (ECR, ACR, GCR)
π Security
βββ IAM Roles & Policies
βββ SSL/TLS Certificates
βββ Secrets Management
| Question | Quick Answer |
|---|---|
| What is Kubernetes? | Container orchestration platform that automates deployment, scaling, and management |
| Why use K8s? | Automated scaling, self-healing, rolling updates, service discovery, load balancing |
| EKS vs AKS vs GKE? | EKS=AWS integration, AKS=best free tier, GKE=easiest to use |
| Pod vs Container? | Pod wraps containers, smallest K8s unit; containers are the actual app |
| Why not always VMs? | Containers are lighter (MBs vs GBs), faster (seconds vs minutes), cheaper |
| How does scaling work? | HPA scales pods, Cluster Autoscaler scales nodes, VPA adjusts resources |
| What's a Service? | Stable network endpoint to access pods (ClusterIP/NodePort/LoadBalancer) |
| ConfigMap vs Secret? | ConfigMap=config data, Secret=sensitive data (base64 encoded) |
| What's etcd? | Key-value store that holds all cluster state and configuration |
| What's kubelet? | Agent on each node that ensures containers are running as expected |
- Official Kubernetes Docs
- kubectl Cheat Sheet
- AWS EKS Documentation
- Azure AKS Documentation
- GCP GKE Documentation
- Star this repo for quick access
- Clone locally for offline reference
- Print the architecture diagram and keep it visible
- Practice commands in a local cluster (minikube/kind)
- Review before interviews - focus on the quick answers section
Found an error or want to add more? Feel free to submit a PR!
Made with β€οΈ codiebyheaart
Last Updated: December 2025