Cluster Orchestration in 3D
Control Plane schedules pods onto worker nodes. Press Scale Up to add pods. Press Kill a Node to watch self-healing reschedule them automatically.
Code example
A Deployment YAML and the kubectl commands to manage it.
# deployment.yaml — describe desired state; K8s makes it real
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment
spec:
replicas: 3 # always run 3 pods
selector:
matchLabels:
app: api
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1 # spin up 1 new before killing old
maxUnavailable: 0 # never drop below 3 healthy pods
template:
metadata:
labels:
app: api
spec:
containers:
- name: api
image: myapp:1.4.2
ports:
- containerPort: 3000
resources:
requests: { cpu: "100m", memory: "128Mi" }
limits: { cpu: "500m", memory: "512Mi" }
readinessProbe:
httpGet: { path: /health, port: 3000 }
initialDelaySeconds: 5
periodSeconds: 10
# Apply the deployment (create or update)
kubectl apply -f deployment.yaml
# Watch pods come up in real time
kubectl get pods -w
# Scale manually (overrides YAML until next apply)
kubectl scale deployment api-deployment --replicas=5
# Rolling update to new image version
kubectl set image deployment/api-deployment \
api=myapp:1.4.3
# Watch rollout progress
kubectl rollout status deployment/api-deployment
# Roll back if the new version is broken
kubectl rollout undo deployment/api-deployment
# See logs from a running pod
kubectl logs -f deployment/api-deployment
# Shell into a pod for debugging
kubectl exec -it \
$(kubectl get pod -l app=api -o jsonpath='{.items[0].metadata.name}') \
-- /bin/sh
Key concepts
Control Plane
The brain of the cluster. The API server is your interface (kubectl talks to it), the scheduler places pods on nodes, and etcd stores all cluster state as key-value pairs.
Pod
The smallest schedulable unit. Pods are ephemeral — they can be killed and replaced at any time. Never store persistent state in a pod's filesystem. Use PersistentVolumes or external databases.
ReplicaSet
Declares that N copies of a pod must always be running. If a pod crashes, the ReplicaSet controller creates a replacement. Deployments wrap ReplicaSets to add rolling update logic.
Service
Gives a stable virtual IP and DNS name to a dynamic set of pods. kube-proxy routes traffic to healthy pods. Types: ClusterIP (internal), NodePort (external), LoadBalancer (cloud LB).