→ From Coder to Shipper
From Coder to Shipper · DevOps

Kubernetes (k8s)

The container orchestrator: software that runs and manages MANY containers across MANY machines — automatically.

← / → to navigate · EN/VI switch below

The basics

What is Kubernetes?

Kubernetes (k8s) = the container orchestrator — software that runs and manages MANY containers across MANY machines, automatically.

The orchestrator

You tell it what you want; it decides where each container runs and keeps it running.

Many containers, many machines

Not one app on one VPS — dozens or hundreds of containers spread across a pool of machines.

It sits on top of Docker

Docker builds the box; k8s flies the fleet. It doesn't replace Docker — it manages the containers Docker (or similar) makes.

Automatic

A machine dies, a container crashes, traffic spikes — k8s notices and fixes it without a human.

The big picture

Docker vs Kubernetes

One box vs the air traffic control for many boxes.

Docker — one box

Packages ONE app with everything it needs into a single container — a portable box that runs the same on your laptop and on the server.

Great for one app. It doesn't answer: which machine runs it? what if it crashes? how do I run 3 copies?

Kubernetes — the air traffic control

Runs and manages MANY such boxes across MANY machines — places them, restarts them, scales them, swaps versions — automatically.

You describe the goal ('3 copies of hello'); k8s keeps the sky in order.

What it does

Describe the goal — it keeps it true

You don't run commands per machine. You declare a state ('3 copies of my app'), and k8s constantly works to make reality match it.

Schedules

Decides which machine (node) each container lands on, spreading the load across the pool.

Self-heals

A container crashes or its machine dies → k8s starts a replacement, often on another node, in seconds.

Scales

Change replicas from 3 to 10 — new copies appear. Scale back down and they're gone. No machine by machine.

Rolls out + load-balances

New version? Containers are swapped one-by-one without downtime. Traffic is split evenly across the running copies.

01
Part 1

Core concepts (the light version)

Five words: cluster, node, pod, deployment, service.

Vocabulary

Five words you must know

That's the whole vocabulary you need to read a deployment file.

cluster

The whole thing: a pool of machines working together to run your containers.

node

One machine in the cluster (a server or VM) that runs containers.

pod

The smallest unit: a group of 1+ containers that live together (almost always just one).

deployment

'Run N replicas of this pod, and keep it true.' The object you edit most — it drives restarts, rollouts and scaling.

service

A stable name + port for a group of pods. Pods come and go; the service's address never changes.

The picture

A cluster: nodes, and pods on them

3 nodes, 3 pods — one per node. The service gives all three pods one shared front door.

CLUSTER — the whole thing

🖥 node-1

📦 pod · hello

🖥 node-2

📦 pod · hello

🖥 node-3

📦 pod · hello

↕ service "hello-svc" — one stable name + port for all three pods

If node-2 dies, k8s re-places that pod on another node — the cluster stays at 3 running copies.

The loop

How k8s keeps your goal true

A controller loop, running every second, forever.

  1. 1

    You declare the goal

    A YAML file: 'run 3 replicas of image hello, port 80'. You `kubectl apply` it once.

  2. 2

    k8s schedules the pods

    The scheduler picks a node for each of the 3 pods — spreading them out, respecting each machine's capacity.

  3. 3

    It watches everything

    The control plane constantly checks: are 3 pods actually running? Right image? Port open?

  4. 4

    It fixes what's off

    Pod crashed → a new one. Node died → its pods move elsewhere. Load up → more replicas. You never do this by hand.

The why

When you'd reach for k8s

Rule of thumb: many containers × many servers → k8s. One small site → not yet.

Many containers across many servers

A monolith is one app on one VPS. A real product grows into many services, each with several copies — something has to place, restart and scale them all.

Self-healing + scaling without handwork

2 a.m. crash → k8s already restarted it. Traffic spike → replicas go 3 → 30 → back to 3. No human in the loop.

Honest note: overkill for one small site

One app, one VPS? Docker + nginx is enough and far simpler. k8s earns its keep once the fleet of containers outgrows hand management.

Example 1 · YAML

A tiny deployment: 3 copies of my app

This file IS the goal: 3 replicas, image nginx:1.27, port 80.

deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
spec:
  replicas: 3
  selector:
    matchLabels: {app: hello}
  template:
    spec:
      containers:
        - name: hello
          image: nginx:1.27
          containerPort: 80

replicas: 3 is the whole ask — k8s works non-stop to keep exactly 3 running.

Example 2 · YAML

A service: one stable name for the pods

Pods get brand-new names every time they're recreated — the service's name and port never change.

service.yaml
apiVersion: v1
kind: Service
metadata:
  name: hello-svc
spec:
  selector:
    app: hello
  ports:
    - port: 80
      targetPort: 80

selector finds every pod labelled app: hello; clients just talk to hello-svc:80.

In the terminal

kubectl: apply it, watch it

`kubectl` is your remote control for the cluster — two commands cover 80% of daily life.

ops@vps — zsh
$ kubectl apply -f deploy.yaml
deployment.apps/hello created
$ kubectl apply -f service.yaml
service/hello-svc created
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-7d4b9c8f5-2xk9p 1/1 Running 0 42s
hello-7d4b9c8f5-8m3qa 1/1 Running 0 42s
hello-7d4b9c8f5-t7w2r 1/1 Running 0 41s
3 pods — exactly what the deployment asked for
The landscape

Names you'll actually meet

k8s itself is open source; in practice you run a managed version from your cloud — or a tiny one at home.

GKE / EKS / AKS

Managed k8s from Google, Amazon and Azure — the cloud runs the control plane, you just deploy. The default choice for most teams.

k3s / minikube / kind

Tiny k8s that runs on your laptop or a single VPS — perfect for learning and small projects.

kubectl

The command-line remote control — the same tool works with every k8s above, managed or not.

Out of scope

What we're deliberately skipping

k8s has a deep toolbox. These are real — but not your next step.

namespaces

Logical partitions of one cluster (staging vs prod). Useful later — the default namespace works fine to start.

ingress

How the outside internet reaches your services (URLs, TLS, routing). A whole topic of its own.

Helm

The package manager for k8s — reusable 'charts' for common apps. You'll meet it after the basics.

operators

Custom controllers that automate whole systems (databases, queues…). Powerful, advanced.

scheduling internals

How the scheduler scores and picks nodes. Knowing 'it places pods for you' is enough here.

Docker packs one app into a box. Kubernetes is the air traffic control that flies many such boxes across many machines — placing, restarting and scaling them, automatically.
the big picture

Many boxes, zero babysitting.

Next: put one deployment YAML on a small cluster — k3s on a VPS is a great first run.