Skip to main content

Kubernetes — Core Concepts

Kubernetes schedules containers across nodes, self-heals failed pods, and manages scaling — you declare desired state, it reconciles.

When to use

  • More than 3 services requiring auto-scaling, self-healing, and rolling deployments
  • When you need declarative infrastructure for containerized workloads

Tradeoffs

  • Steep learning curve; ~15+ resource types to understand
  • etcd as SPOF if not HA; overkill for single-service apps
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
replicas: 3
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: myapp:1.4.2
ports:
- containerPort: 8080
resources:
requests: { cpu: "100m", memory: "128Mi" }
limits: { cpu: "500m", memory: "256Mi" }
---
apiVersion: v1
kind: Service
metadata:
name: api
spec:
selector:
app: api
ports:
- port: 80
targetPort: 8080

Gotcha: A Pod is ephemeral — it can be killed and rescheduled at any time. Never store state in a Pod without a PersistentVolume. Always use a Deployment, never create Pods directly.