LOOP · The DevOps Codex
Ch 09 · Kubernetes
Chapter 09 · Orchestration

Kubernetes — the planetary control plane

Kubernetes is the de-facto operating system for distributed workloads: a declarative, API-driven control plane that turns a fleet of machines into a single programmable substrate. This chapter walks the architecture, every workload primitive, the networking and storage abstractions, the autoscaling stack, the operator pattern, and the security baselines you cannot skip in 2026.

9.1 · What Kubernetes actually is

Definition. Kubernetes (often k8s — eight letters between k and s) is an open-source container orchestrator that exposes a declarative REST API: you submit a desired state, a set of controllers continuously reconciles the cluster toward it. Google open-sourced the project in June 2014, drawing on a decade of internal experience with Borg and its successor Omega; it was the first project ever to graduate at the CNCF (March 2018). Current stable line is v1.30 "Uwubernetes" (Apr 2024) through v1.33 (2025).

Mental model
Kubernetes is a thermostat, not a script. You set the target ("3 replicas, 200m CPU, image v2.4"), and the controller loop drives reality toward that target — forever.
YearMilestoneWhy it matters
2003Google Borg startsCell-based cluster manager — the intellectual ancestor.
2014K8s v0.1 open-sourcedJoe Beda, Brendan Burns, Craig McLuckie at Google.
2015v1.0 + CNCF foundedK8s is the seed project; Linux Foundation neutral home.
2018CNCF graduationFirst graduated project; "boring" production-ready.
2020Dockershim deprecatedCRI-only — containerd / CRI-O win the runtime slot.

9.2 · Control plane & node components

A cluster is split into a control plane (the brain) and one-or-more nodes (the muscles). Every action flows through the API server.

PlaneComponentRole
Controlkube-apiserverStateless REST front-end; only component that talks to etcd.
etcdDistributed key-value store (Raft). Single source of truth.
kube-scheduler / -controller-managerPicks nodes for Pods; runs core controllers (Deployment, Node, SA…).
cloud-controller-managerCloud-specific: load balancers, node lifecycle, routes, volumes.
NodekubeletPer-node agent; talks to runtime via CRI, reports pod status.
kube-proxyPrograms iptables / IPVS / nftables for Service VIPs (eBPF in Cilium).
CRI runtimecontainerd (EKS/GKE/AKS) or CRI-O (OpenShift) → runc / crun.
control plane kube-apiserver etcd (Raft) scheduler controller-mgr worker node kubelet kube-proxy containerd / CRI-O (CRI)

9.3 · Workload primitives — the full table

KindWhat it isWhen to use
PodSmallest deployable unit: one-or-more containers sharing net + IPC + volumes.Almost never created directly — always via a controller.
ReplicaSetKeeps N identical Pods running.Implementation detail of Deployment.
DeploymentDeclarative ReplicaSet w/ rolling updates & rollback.Stateless services — the default workload.
StatefulSetStable identity (web-0, web-1), ordered rollout, per-pod PVC.Databases, brokers — anything needing identity.
DaemonSetOne Pod per node (or per matching node).Log shippers, CNI agents, node exporters.
JobRun to completion; retries on failure.Migrations, batch ETL.
CronJobJob on a schedule (cron syntax).Nightly reports, cleanup.
ReplicationController legacyPre-1.0 predecessor of ReplicaSet.Do not start new clusters with it.

9.4 · Service primitives

A Service is a stable virtual IP + DNS name in front of a churning set of Pods. The endpoints controller writes EndpointSlice objects (replaces Endpoints at scale, GA in v1.21).

TypeWhat it doesBacked by
ClusterIPInternal VIP only.kube-proxy / Cilium.
NodePortOpens port 30000–32767 on every node.iptables/IPVS rules.
LoadBalancerProvisions a cloud LB (ELB/ALB, GCLB, Azure LB).cloud-controller-manager.
ExternalNameCNAME alias to an external host.CoreDNS.
Headless (clusterIP: None)DNS returns Pod IPs directly — no VIP.StatefulSet workloads.
IngressHTTP/S routing by host/path. Controllers: NGINX, HAProxy, Traefik, Istio, Contour.L7 proxy.
Gateway API GA v1.0 Nov 2023Role-oriented (Infra/Cluster/App), expressive, multi-protocol replacement for Ingress.Envoy Gateway, Istio, Kong, Cilium.

9.5 · Config & storage

  • ConfigMap / Secret — key/value config mounted as env or files. Secrets are base64, not encrypted (turn on KMS provider via EncryptionConfiguration).
  • PV / PVC / StorageClass — cluster volume + Pod claim + dynamic-provisioner template (e.g. gp3, premium-rwo).
  • CSI — Container Storage Interface; only supported volume plugin model since v1.21. Snapshots GA v1.20.

9.6 · Networking — CNI plugins

The Kubernetes networking model demands flat L3: every Pod gets a routable IP, every Pod can reach every other Pod without NAT. A CNI (Container Network Interface, spec v1.0.0 2022) plugin makes that happen.

CNIDataplaneNotable features
Calico (Tigera)BGP / VXLAN / eBPFMature NetworkPolicy, optional eBPF mode.
Cilium (Isovalent → Cisco; CNCF graduated Oct 2023)eBPFL3-L7 policy, Hubble observability, kube-proxy replacement, Gateway API.
FlannelVXLAN overlaySimplest; no NetworkPolicy.
Weave NetVXLANEnd-of-life since Mar 2024.
AWS VPC CNIENIs & secondary IPsPod IPs are VPC IPs — native routing, security-group support.
Azure CNIVNet IPs or overlayCilium-powered "Azure CNI Overlay" since 2024.
GKE Dataplane v2eBPF (Cilium)Default for new GKE clusters since 2021.

9.7 · Autoscaling — four axes

  • HPA — Horizontal Pod Autoscaler: replicas on CPU/mem/custom metrics (autoscaling/v2 GA v1.23).
  • VPA — Vertical Pod Autoscaler: recommend or auto-resize requests/limits.
  • KEDA — event-driven scaling (Kafka lag, queue depth, cron, 60+ scalers); scales to zero. CNCF graduated Aug 2023.
  • Cluster Autoscaler — adds/removes nodes from cloud node-groups when Pods can't schedule.
  • Karpenter — AWS-origin (donated to CNCF Nov 2023); JIT, instance-type-aware; replaces CA on EKS.
  • Goldilocks — Fairwinds dashboard over VPA recommendations.

9.8 · Operators & CRDs

Definition. An Operator is a custom controller plus a CustomResourceDefinition (CRD) that encodes operational knowledge for a specific app (e.g. "how to fail over Postgres"). Pattern coined by CoreOS in November 2016.

SDKs: Operator SDK (Go/Ansible/Helm — OpenShift world), Kubebuilder (Go, upstream-blessed), kopf (Python), Metacontroller (webhook-based, any language).

Famous operators in 2026: cert-manager External Secrets Strimzi (Kafka) CloudNativePG Prometheus Operator Argo CD Crossplane.

9.9 · Packaging — Helm vs Kustomize vs Carvel vs Jsonnet

ToolApproachStrengthsWeaknesses
Helm 3Go templating + values.yamlLargest chart ecosystem (Artifact Hub), OCI registries.YAML-in-string templating is error-prone.
KustomizeOverlay / patch (no templating)Native in kubectl -k since v1.14; readable diffs.No parameterisation for complex apps.
Carvel (ytt, kapp, kbld)YAML-aware templating + dependency-aware applyStrong typing, sandboxed templating.Smaller community.
Jsonnet (Tanka, kubecfg)Real DSL, functions, inheritanceBest for large mono-repos (Grafana Labs use it).Learning curve.
cdk8sTS / Python / Go → YAMLReal language, IDE support.Build step in the loop.

9.10 · Distros & managed offerings

  • Managed (cloud): EKS (AWS, 2018), GKE (Google, 2015 — Autopilot 2021), AKS (Azure, 2018). EKS now charges $0.10/h control plane.
  • Enterprise distros: OpenShift (Red Hat / OKD), Rancher (SUSE), VMware Tanzu, Mirantis MKE.
  • Lightweight / edge: K3s, K0s, MicroK8s, Talos Linux (immutable, API-driven OS).
  • Local / CI: kubeadm, Kind (Docker-in-Docker), k3d, minikube.

9.11 · Security baselines

Pod Security Standards (PSS) replaced PodSecurityPolicy in v1.25 (Aug 2022): three profiles — Privileged (allow all, for CNI/CSI), Baseline (no hostNet/PID, no privileged, no dangerous caps), Restricted (no runAsRoot, no privilege-escalation, drop all caps except NET_BIND_SERVICE, seccomp=RuntimeDefault).

  • RBAC — Roles & ClusterRoles with verbs (get/list/watch/create/update/patch/delete) on resources.
  • ServiceAccount tokens — projected, audience-scoped, time-bound (BoundServiceAccountTokenVolume GA v1.22).
  • NetworkPolicy — default-deny ingress/egress, then explicitly allow. Cilium adds L7 (HTTP/gRPC/Kafka) rules.
  • Admission control — Validating/Mutating webhooks; policy engines Kyverno (CNCF graduated Nov 2024) and OPA Gatekeeper.
  • Image & supply chain — Sigstore cosign verify-attestations via admission (e.g. Connaisseur, Kyverno verifyImages).

9.12 · Observability for K8s

kubelet /metrics
→
metrics-server
→
HPA
·
API objects
→
kube-state-metrics
→
Prometheus
  • metrics-server — lightweight, in-memory; powers kubectl top and HPA.
  • kube-state-metrics (KSM) — emits the state of objects (Deployments, Pods, Jobs) as Prometheus metrics.
  • kube-prometheus-stack — the canonical Helm chart bundling Prometheus Operator, Alertmanager, Grafana, KSM, node-exporter.
  • OpenTelemetry Operator — auto-instruments workloads & runs OTel Collector as a DaemonSet/sidecar.
Anti-pattern
Treating Kubernetes as a PaaS without a platform team. K8s gives you Lego bricks, not a product — without paved roads (Backstage / IDP / Helm baselines) developer cognitive load explodes.

9.13 · Self-check

Q1 · Which component is the only one allowed to talk to etcd?
kube-scheduler
kube-apiserver
kubelet
kube-controller-manager
Q2 · You need stable network identity and per-Pod storage for a 3-node Postgres. Which workload kind?
Deployment
DaemonSet
StatefulSet
Job
Q3 · Which autoscaler is best for scale-to-zero on Kafka consumer lag?
HPA alone
VPA
KEDA
Cluster Autoscaler