Blog→Infrastructure
DevOps

Kubernetes for developers: how container orchestration works

2 Jun 2026 · approx. 16 min read

You package an application into a container and start it with docker run. But who restarts it when it crashes at three in the morning? Who moves it when a whole server dies? And who adds more instances when a peak arrives? These are exactly the questions Kubernetes answers — and it does so in a way that is more elegant than its reputation as a “bloated behemoth” might suggest. In this article we break down its key idea (the declarative model and the reconciliation loop), the cluster architecture, the basic objects and practical examples. And we’ll also be honest about when you don’t need Kubernetes.

Aerial view of a container terminal full of colourful containers

Kubernetes is Greek for “helmsman” — the pilot who steers a cargo of containers. Photo: Tom Fisk, Pexels

Quick intuition

Kubernetes is not a magic server but a set of controllers. You describe what the system should look like, and the controllers keep correcting reality over and over so that it approaches this description.

Why orchestration at all

Containers solved packaging an application: code, dependencies and runtime in one portable bundle. But they don’t solve operations. As soon as you have more than a few containers on more than one machine, questions start piling up that docker run has no answer to:

  • Scheduling — on which machine should the container run so that CPU and memory are used efficiently?
  • Self-healing — who restarts a crashed process and what happens when a whole server goes down?
  • Scaling — how to add instances at peak and remove them at night without someone doing it by hand?
  • Deployment — how to release a new version without downtime and how to roll back quickly when it’s broken?
  • Networking and discovery — how do instances find each other when their IP addresses keep changing?

Kubernetes (K8s for short — eight letters between K and s) is the open-source answer to all these questions at once. It originated at Google as a distillation of experience from the internal Borg system, was released as open source in 2014 and is today governed by the CNCF foundation. It is the de facto standard: all the big clouds offer managed Kubernetes (EKS, GKE, AKS) and the vast majority of cloud-native tools assume it as their foundation.

The key idea: the declarative model and the reconciliation loop

If you should take away a single thing from this whole article, let it be this. You don’t command Kubernetes imperatively (“start three containers”) but declaratively: you describe the desired state (“I want three replicas of this application running”) and Kubernetes takes care that the actual state of the cluster matches it. Continuously.

This is ensured by controllers — programs that do three steps in an infinite loop: observe the actual state, compare it with the desired state written in the object’s spec field and act so that the difference shrinks. This loop is called the reconciliation loop and it is the most important design pattern of the whole system — every Kubernetes feature, from Deployments to autoscaling, is just another controller with the same loop.

Diagram of the Kubernetes reconciliation loop
Diagram of the Kubernetes reconciliation loop
The reconciliation loop: the controller endlessly brings the actual state of the cluster closer to the desired one.

Two properties follow from the loop, thanks to which Kubernetes survives even the chaos of real operations:

  • Level-triggered behaviour — the controller doesn’t react to individual events (“the user changed replicas from 3 to 5, then to 4”) but always to the current state. When a controller crashes or misses events, after restart it simply looks again and computes the difference. No lost message causes permanent inconsistency.
  • Idempotence — every reconciliation can be safely run repeatedly. Creating a Pod that already exists is a no-op; scaling to a count that already holds does nothing. That’s why the loop can spin every few seconds without breaking the system.

This pattern is so universal that extending Kubernetes is built on it too: you write your own object type (Custom Resource Definition) and your own controller — this is called an operator — and suddenly Kubernetes can manage, say, a PostgreSQL cluster or certificates in the same way it manages Pods.

Architecture: control plane and worker nodes

Physically, a Kubernetes cluster is a set of machines (physical or virtual) divided into two roles. The control plane is the brain: it holds state, schedules and decides. Worker nodes are the muscles: your containers actually run on them.

Kubernetes cluster architecture
Kubernetes cluster architecture
The control plane decides, worker nodes execute. All communication goes through kube-apiserver.

Control plane components

  • kube-apiserver — the only place through which one communicates with the cluster. A REST API through which everything goes: kubectl, controllers and the kubelets on the nodes. It validates objects and stores them in etcd.
  • etcd — a distributed key-value database in which the complete state of the cluster lives (all objects and their spec and status). The only stateful component — everything else can be restarted without data loss.
  • kube-scheduler — watches Pods without an assigned node and selects the most suitable machine for them according to CPU/memory requirements, affinities and other rules.
  • kube-controller-manager — hosts dozens of built-in controllers (Deployment, ReplicaSet, Job, Node…), each with its own reconciliation loop.

What runs on worker nodes

  • kubelet — the agent that asks the API server which Pods should run on the node, and starts and watches them via the container runtime.
  • container runtime — typically containerd, the actual running of containers. (Docker as a runtime is gone, but images from Docker of course still work — the OCI format is shared.)
  • kube-proxy — maintains the network rules so that Services work (see below).

Basic objects: from Pod to Deployment

You work with Kubernetes through objects — YAML manifests that describe the desired state. The basic kit is small and nests like a matryoshka doll:

Object What it’s for Typical question it answers
Pod The smallest deployable unit: one or more containers with shared network and disk “What exactly is running?”
ReplicaSet Keeps the specified number of identical Pods alive “How much of it is running?”
Deployment Manages ReplicaSets and can do rolling updates and rollbacks “How do I release a new version?”
Service A stable name and IP in front of a changing set of Pods, load balancing “How do I connect to it?”
Ingress / Gateway HTTP(S) entry into the cluster from outside, routing by domains and paths “How do I expose it to the world?”
ConfigMap / Secret Configuration and sensitive data separated from the image “Where do I get the connection string?”
Namespace Logical separation of objects (teams, environments) “How do I keep it tidy?”

An important detail: Pods are disposable. When a Pod dies, nobody repairs it — the ReplicaSet simply creates a new one, possibly on a different machine and with a different IP address. That’s why Services exist: they give a changing set of Pods a stable DNS name (e.g. api.default.svc.cluster.local) and distribute traffic among them. A Service selects Pods by labels — ordinary key-value tags.

A practical example: deploying an application

This is what a complete manifest for deploying a web application in three replicas with a Service looks like:

YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: moje-api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: moje-api
  template:
    metadata:
      labels:
        app: moje-api
    spec:
      containers:
        - name: api
          image: registry.example.com/moje-api:1.7.0
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: 250m        # 0.25 CPU pro planovani
              memory: 256Mi
            limits:
              memory: 512Mi    # tvrdy strop, pri prekroceni OOMKill
---
apiVersion: v1
kind: Service
metadata:
  name: moje-api
spec:
  selector:
    app: moje-api      # smeruj na Pody s timto labelem
  ports:
    - port: 80
      targetPort: 8080

You send the manifest to the cluster and watch the reconciliation loops do their work:

Bash
$ kubectl apply -f moje-api.yaml
deployment.apps/moje-api created
service/moje-api created

$ kubectl get pods -l app=moje-api
NAME                        READY   STATUS    RESTARTS   AGE
moje-api-7d4b9c8f6d-2xvqp   1/1     Running   0          14s
moje-api-7d4b9c8f6d-8kzwl   1/1     Running   0          14s
moje-api-7d4b9c8f6d-tr9nc   1/1     Running   0          14s

You can try self-healing right away: delete one Pod manually and watch the ReplicaSet controller top the state back up to three replicas within a few seconds.

Bash
$ kubectl delete pod moje-api-7d4b9c8f6d-2xvqp
pod "moje-api-7d4b9c8f6d-2xvqp" deleted

$ kubectl get pods -l app=moje-api
NAME                        READY   STATUS    RESTARTS   AGE
moje-api-7d4b9c8f6d-8kzwl   1/1     Running   0          3m
moje-api-7d4b9c8f6d-tr9nc   1/1     Running   0          3m
moje-api-7d4b9c8f6d-x51fh   1/1     Running   0          4s    # novy Pod, dopocital ho kontroler

And a new version? You change the image tag in the manifest (or use kubectl set image) and the Deployment controller performs a rolling update: it gradually creates Pods with the new version and only when they are healthy removes the old ones. When something goes wrong, kubectl rollout undo restores the previous revision.

Bash
$ kubectl set image deployment/moje-api api=registry.example.com/moje-api:1.8.0
$ kubectl rollout status deployment/moje-api
Waiting for deployment "moje-api" rollout to finish: 1 out of 3 new replicas have been updated...
deployment "moje-api" successfully rolled out

How Kubernetes knows the application is healthy

Rolling updates and self-healing stand and fall with Kubernetes being able to distinguish a healthy Pod from a sick one. That’s what probes are for, which the kubelet periodically runs against the container:

  • Liveness probe — “are you alive?” When it fails repeatedly, the kubelet restarts the container. Useful for stuck processes and deadlocks.
  • Readiness probe — “are you ready to serve?” When it fails, the Pod is temporarily removed from the Service and receives no traffic — for instance during warm-up or while waiting for the database.
  • Startup probe — protection for slow-starting applications; until it passes, liveness is not evaluated.
Text only
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8080
            periodSeconds: 10
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /ready
              port: 8080
            periodSeconds: 5

A common mistake: putting dependency checks (database, queues) in the liveness probe. When the database then goes down, Kubernetes starts restarting all your Pods — and a minor outage becomes a cascading catastrophe. Liveness should test only the process itself; dependencies belong at most in readiness.

Scaling: manual, automatic, and what to watch out for

Manual scaling is one command (kubectl scale deployment/moje-api --replicas=10), but the automatic kind is more interesting. The Horizontal Pod Autoscaler (HPA) is — how else — another controller: it watches metrics (typically CPU utilisation relative to requests) and adjusts the number of replicas within a given range.

YAML
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: moje-api
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: moje-api
  minReplicas: 3
  maxReplicas: 20
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70

For the HPA (and the scheduler in general) to work sensibly, it needs to know the resources.requests of your containers — scheduling and utilisation are computed from them. Deploying production workloads without requests is one of the most common beginner mistakes: the scheduler then overfills machines and applications starve each other. Besides the HPA there is also the Vertical Pod Autoscaler (adjusts requests) and the Cluster Autoscaler (adds whole nodes in the cloud) — together they form three layers of elasticity.

Where to try Kubernetes

You don’t need a corporate cluster; you can run a full-fledged Kubernetes on your own laptop:

  • kind (Kubernetes in Docker) — a cluster in containers, ideal for quick experiments and CI. Starts within a minute.
  • minikube — the oldest and most convenient option, with add-ons (dashboard, ingress) in one command.
  • k3s — a lightweight certified distribution (a single ~70 MB binary), great even for Raspberry Pi and edge.
Text only
# cely playground na tri prikazy (potrebujete jen Docker)
$ kind create cluster --name pokusy
$ kubectl cluster-info --context kind-pokusy
$ kubectl apply -f moje-api.yaml

In production the overwhelming majority of companies then reach for a managed service — Amazon EKS, Google GKE or Azure AKS — where the cloud runs the control plane and you deal only with worker nodes and your applications.

Gantry crane loading containers onto a ship

Orchestration in the original sense: you don’t deal with the crane, you only say where the cargo should arrive. Photo: lucas hegaard, Pexels

What Kubernetes is not (and when not to use it)

Honesty to finish: Kubernetes is powerful, but it isn’t free. It is not a PaaS — you don’t get a build pipeline, databases or monitoring; you install and manage all of that in it yourself. And its complexity is real: network models, RBAC, certificates, cluster upgrades three times a year.

  • One application on one server? Docker Compose + systemd will serve you for a fraction of the effort.
  • A small team without ops capacity? A PaaS (Fly.io, Railway, Azure App Service…) solves 90% of needs without having to understand etcd.
  • Kubernetes makes sense when you run dozens of services, need autoscaling, multi-tenant isolation, a unified platform for multiple teams — or special workloads like GPU inference (see our article on hosting LLMs, where Kubernetes plays the main role at large scale).

Rule of thumb: get Kubernetes when its absence starts to hurt — not because everyone around you has it. Migrating from Compose to K8s is much cheaper than a year of premature complexity.

Kubernetes in 2026

The project releases three versions a year; the current one is v1.36 “Haru” from April 2026 (70 enhancements, 18 of them newly stable). The direction in which the project is developing is worth noting:

  • AI and batch workloads — Workload Aware Scheduling (gang scheduling, PodGroup API) targets distributed training and inference, where a group of Pods needs to be scheduled atomically, “all or nothing”. Dynamic Resource Allocation (DRA) for flexible GPU allocation is gradually maturing to stable.
  • Declarative API validation — validation of native types is generated from declarative rules instead of hand-written code; over time the rules will propagate into OpenAPI schemas, so errors will be caught by the editor already.
  • Clean-up — the old gitRepo volume has been definitively removed and Service.spec.externalIPs is deprecated (CVE-2020-8554). Before a cluster upgrade it pays to audit deprecated APIs.

What to do about it in practice

For a specific cloud scenario, the article How to host AI agents on AWS follows on, where we compare Lambda, ECS Fargate and AgentCore.

  • Start with a managed cluster and local kind — learn to run your own control plane only when you really need to.
  • Always set resources.requests and, for memory, limits too; without them neither the scheduler nor autoscaling works properly.
  • The liveness probe tests only the process, not dependencies — you’ll spare yourself cascading restarts.
  • Manifests belong in git — the declarative model directly invites a GitOps approach (Argo CD, Flux): git is the desired state, the cluster reconciles with it. The same loop, one layer up.
  • Learn to debug: kubectl describe pod (events!), kubectl logs --previous, kubectl exec. The answer to 80% of problems is in the events.
  • Don’t succumb to template hell — before reaching for Helm with three layers of values, try plain manifests and Kustomize. Add complexity only when its absence hurts.

Want Kubernetes and containers in practice?

The basics of Linux, Docker and DevOps are covered by the Start with Linux and DevOps course. If the combination of Kubernetes and AI attracts you, take a look at the Artificial Intelligence for Programmers, Science and Data Analytics course or read how to scale open-source LLMs with vLLM. We arrange tailored corporate training via contact.

Sources and further reading

Zdeněk Vais

About the author

Zdeněk Vais

Founder · Senior Principal Software Engineer, Oracle

Zdeněk has been programming since high school. Since then he has gone from programmer through team leader to architect, building large financial systems, scientific applications and IoT solutions for aircraft along the way. He currently works as a senior principal software engineer at Oracle, where he builds the cloud for media services.

Meet our team

← Back to all articles