Module 6 · Reliability and infrastructureLesson 70 of 888 minIntermediate

Kubernetes fundamentals

Kubernetes runs containers across a fleet of machines. You declare what you want running, and it keeps working to make that true.

Try it

Change the desired pod count and watch Kubernetes add or remove pods. Kill a pod, then kill a whole node, and watch it heal.

Kubernetes (K8s) is the standard platform for running containers in production.

The core idea: desired state

You don't tell Kubernetes what to do; you tell it what you want:

kind: Deployment
spec:
  replicas: 4
  template: { containers: [{ image: shop:v42 }] }

Controllers run in a loop: compare desired state with actual state, and act to close the gap. A pod crashed? Start another. You changed the image? Replace pods gradually. This is called reconciliation.

Key objects

  • Pod: one or more containers that run together, with a shared network address. The smallest unit.
  • Deployment: keeps N identical pods running and handles rolling updates and rollbacks.
  • Service: a stable name and IP that load-balances across a set of pods, even as pods come and go.
  • Ingress / Gateway: routes outside HTTP traffic to services.
  • ConfigMap / Secret: configuration and credentials, injected into pods.
  • StatefulSet: for databases and other apps that need stable identities and storage.
  • Node: a machine (VM or physical) that runs pods.

The control plane

  • API server: everything talks to it; all changes go through it.
  • etcd: a consensus-backed store holding the cluster's state.
  • Scheduler: decides which node runs each new pod, based on requested CPU and memory.
  • Controller manager: runs the reconciliation loops.

What you get, and what you don't

You get self-healing, rolling deploys, service discovery, scaling (including the Horizontal Pod Autoscaler) and a common way to run everything.

You don't get magic capacity: if the nodes are full, new pods stay Pending. And Kubernetes is complex to operate; managed versions (EKS, GKE, AKS) take care of the control plane. For small apps, simpler platforms may be enough.

Quick check

A node with 3 of your pods dies. What does Kubernetes do?