A note for the harbour master
You don't dock ships yourself. You give the harbour master a note: "I want three of these ships docked at all times." The harbour master looks at the harbour, sees none, and calls three in, choosing berths with room.
Desired state
Containers solve packaging; running hundreds of them across many machines needs an orchestrator. In Kubernetes you write declarative manifests:
1apiVersion: apps/v12kind: Deployment3metadata: { name: orders }4spec:5replicas: 36selector: { matchLabels: { app: orders } }7template:8metadata: { labels: { app: orders } }9spec:10containers:11- name: orders12image: shop/orders:1.4
kubectl apply stores it in the control plane (API server backed by etcd). The scheduler places pods (one or
more containers) on nodes, and the kubelet on each node runs them.
A ship sinks
The harbour master keeps checking. When a ship sinks, nobody has to phone you: the gap is spotted and a replacement is called in. The note still says three, so there will be three.
Reconciliation
Kubernetes is a set of control loops. Each controller watches actual state and acts to make it match desired state.
A crashed container is restarted; a pod lost with its node is recreated elsewhere; a failing liveness probe triggers a
restart. The same loop powers scaling: change replicas, or let a HorizontalPodAutoscaler change it based on CPU.
Swapping the fleet
To upgrade, one new ship docks, and only once it's ready does it take cargo. Then one old ship leaves. Repeat until the fleet is new. The harbour gate never closes.
Services and rolling updates
Pods come and go with new IPs, so a Service gives a stable name and load-balances across ready pods matching a label. An Ingress or Gateway routes outside HTTP traffic to Services.
Changing the image triggers a rolling update: new pods start and join the Service once their readiness probe
passes, old pods drain and stop. A bad release stalls the rollout, and kubectl rollout undo rolls back. Config and
secrets come from ConfigMaps and Secrets.