Blog · Systems ·
Kubernetes in pictures: from your laptop to Argo CD
Docker, nodes, pods, Deployments, Services, Ingress, StatefulSets, Jobs, Helm and Argo CD, one animated diagram at a time, starting from the machine you already know.
- interactive
- kubernetes
- devops
- docker
- helm
- argo-cd
I was asked for some slides to explain Kubernetes to the team. Slides can’t move, and nearly every idea here is about something moving: a pod dying, a replacement appearing, traffic shifting. So this is a set of small animations instead. Each one plays on its own; use Back and Next to go at your own pace.
We start on a machine you know, then build up one piece at a time: first the machines and what runs on them, then how traffic reaches it, then how it all gets shipped.
Part 1: one machine
1. Your laptop
Two apps on one laptop share one OS and one Python. One needs 3.8, the other 3.12, so one of them breaks, and on a teammate’s laptop the versions differ again.
2. docker build: a recipe becomes an image
Each line of a Dockerfile adds a read-only layer. The stack of layers, tagged, is the image.
FROM python:3.12-slim
RUN pip install flask
COPY app.py /app/
CMD python /app/app.py
docker build -t myapp:1.0 .
3. docker run: an image becomes a container
Every container started from an image is an identical, isolated copy. A broken one is thrown away and replaced, not repaired.
docker run -d -p 8080:80 myapp:1.0
docker run -d -p 8081:80 myapp:1.0 # an identical twin
Same image, same behaviour, on any machine with Docker. That solves “works on my machine”. It doesn’t solve the next problem.
4. One machine doesn’t scale
More traffic means more containers until the server is full, and when it dies everything on it goes too. You need several machines and something to place work on them.
That “something” is Kubernetes. You tell it what you want running; it works out where, and keeps it that way.
Part 2: compute
5. Nodes: the machines
A node is a real computer: a physical server, or a VM in someone’s cloud. It brings CPU, memory and a container runtime. Kubernetes pools the nodes and treats them as one big machine.
Nodes are machines. A control plane (API server, scheduler, controllers) decides what runs on them; a kubelet on each node carries it out. You talk only to the control plane, with kubectl.
kubectl get nodes
6. Pods: Kubernetes’ docker run
A pod is the closest thing Kubernetes has to docker run: an image to start, plus how
much CPU and memory it needs. You hand that to the cluster and it picks the node.
Each docker run flag has a pod spec field: name, image, port, environment, and CPU and memory, which the scheduler uses to choose a node.
docker run --name web -p 8080:80 -e MODE=prod --cpus 0.5 --memory 256m nginx:1.27
apiVersion: v1
kind: Pod
metadata:
name: web
spec:
containers:
- name: web
image: nginx:1.27
ports: [{ containerPort: 80 }]
env: [{ name: MODE, value: prod }]
resources:
requests: { cpu: 500m, memory: 256Mi } # what the scheduler reserves
limits: { cpu: 500m, memory: 256Mi } # the hard ceiling
Here’s that pod finding a home:
A pod wraps one or more containers with an IP and shared storage. The scheduler places it on a node with room; that node’s kubelet starts it. A bare pod that dies stays dead.
7. You don’t manage pods
A bare pod is fragile, so in practice you never create one. You create a controller and it creates the pods. There are three you’ll use constantly, and they differ in what they do when a pod dies.
Deployments, StatefulSets and Jobs each create pods from a template and own them. When a pod dies, a Deployment replaces it with a new name, a StatefulSet brings back the same name, and a finished Job leaves it alone.
8. Deployments: keep N of these running
A Deployment keeps a set number of identical pods running, replaces any that die, scales by changing one number, and rolls out a new version a few pods at a time.
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
replicas: 3
selector:
matchLabels: { app: api }
template: # the pod spec from section 6, nested
metadata:
labels: { app: api } # every pod gets this label
spec:
containers:
- name: api
image: myapp:1.0
Most of what you run is a Deployment: web apps, APIs, workers.
9. StatefulSets: pods with a memory
Deployment pods get random names and no lasting storage. StatefulSet pods are named in order (db-0, db-1, db-2), each with its own volume, and a replaced pod comes back with the same name and the same disk.
Use them for databases, queues, anything where which copy matters.
That includes talking to a particular copy. A normal Service picks a pod for you.
A headless Service (clusterIP: None) skips the load balancing and gives every
StatefulSet pod its own DNS name instead, so a client can always write to the
primary:
apiVersion: v1
kind: Service
metadata:
name: db
spec:
clusterIP: None # headless: no virtual IP, one DNS record per pod
selector: { app: db }
ports: [{ port: 5432 }]
# db-0.db.prod.svc.cluster.local -> always db-0
# db-1.db.prod.svc.cluster.local -> always db-1
The StatefulSet points at it with serviceName: db.
10. Jobs: run once, then stop
A Job runs a pod to completion, retrying on failure. A CronJob creates a Job on a schedule.
Part 3: networking
The pods are running. Now something needs to reach them.
11. Services: a stable address
Pod IPs change every time a pod is replaced. A Service has one fixed name and IP, picks its pods by label, and load-balances across whichever ones are ready.
apiVersion: v1
kind: Service
metadata:
name: api # other pods just call http://api
spec:
selector: { app: api }
ports:
- port: 80
targetPort: 8080
Nobody types the Service IP. Cluster DNS gives every Service a name of the form
<service>.<namespace>.svc.cluster.local, and inside the same namespace the short
name is enough, so http://api just works. From another namespace it’s
http://api.prod or the full name.
A Service also causes real things to happen. kube-proxy on every node writes
routing rules for its IP, and type: LoadBalancer gets the cloud to provision an
actual load balancer. Keep that in mind for the next one.
12. Ingress: the front door
An Ingress gives the cluster one public entry point and routes requests to Services by host and path. It usually handles HTTPS too.
13. Ingress, below the surface
That’s the picture most people carry around. But unlike a Service, an Ingress deploys nothing. It is a rule, stored as data, and it does nothing until a program reads it.
The Ingress object sits in the API server. An ingress controller, usually nginx running as pods, watches for it and writes the rule into its nginx config. That nginx is exposed by a Service of type LoadBalancer, which is what creates the cloud load balancer. Requests go load balancer, nginx pod, app pod.
So when an Ingress “doesn’t work”, the place to look is usually the controller’s pods and logs, not the Ingress object.
Part 4: shipping it
14. The YAML pile
That’s the core toolkit. Now try shipping a real app with it.
One app needs five manifests; three environments need three nearly identical copies, all edited by hand, and sooner or later one is missed.
15. Helm: templates and values
A Helm chart is the manifests written once as templates. A small values file per environment fills in the blanks.
# templates/deployment.yaml (a fragment)
spec:
replicas: {{ .Values.replicas }}
template:
spec:
containers:
- image: "myapp:{{ .Values.tag }}"
helm install shop ./chart -f values-prod.yaml
16. Helm releases: history and rollback
Every install or upgrade is a numbered revision. Rolling back writes a new revision that copies a known-good one.
helm upgrade shop ./chart --set tag=1.2
helm history shop
helm rollback shop 2
Helm also knows everything a release created, so helm uninstall shop cleans up
all of it.
17. Argo CD: let Git deploy
Helm still leaves one question open: who runs helm upgrade, from where, with which
values? Argo CD’s answer is nobody. Git does.
Argo CD runs in the cluster, watches a Git repo holding the chart and values, and syncs the cluster to match. A merged PR deploys; a hand edit is detected as drift and reverted.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: shop
namespace: argocd
spec:
source:
repoURL: https://github.com/acme/deploy
path: charts/shop
helm:
valueFiles: [values-prod.yaml]
destination:
server: https://kubernetes.default.svc
namespace: prod
syncPolicy:
automated: { prune: true, selfHeal: true }
The whole ladder
| Problem | Answer |
|---|---|
| “Works on my machine” | Docker image |
| One machine isn’t enough | Kubernetes nodes |
| Run a container on some node | Pod |
| Keep N running, roll out updates | Deployment |
| Stable names and disks | StatefulSet |
| Run to completion, or on a timer | Job, CronJob |
| Pod IPs keep changing | Service |
| Reach it from outside | Ingress + a controller |
| Too much copy-pasted YAML | Helm |
| Who deployed what, and when? | Argo CD |
If you want to go further with the raw objects, I built a clickable cluster you can apply manifests to and a follow-up on state and secrets.