Table of Contents

Learning Kubernetes: Why, What, How, and the Theory Behind It

A structured guide for building real understanding of Kubernetes (K8s) — not just memorizing commands, but understanding the problems it solves and the ideas it's built on.


1. WHY — The Problem Kubernetes Solves

Before learning any tool, understand what pain it removes.

1.1 The world before Kubernetes

1.2 The problem containers alone don't solve

Once you have containers, new questions appear:

Doing this manually across a fleet of servers doesn't scale. You need a system that treats a cluster of machines as one programmable unit, and constantly works to keep your application in the state you asked for.

1.3 Why Kubernetes specifically

Core idea to hold onto: Kubernetes is an orchestrator. Docker/containers give you the packaging; Kubernetes gives you the management of many containers across many machines.


2. WHAT — Core Concepts and Theory

This is the conceptual model. Understanding this deeply matters more than memorizing YAML syntax.

2.1 The control loop theory (the single most important idea)

Kubernetes is built on control theory — the same principle behind a thermostat.

  1. You declare a desired state (e.g., “3 replicas of nginx running”).
  2. Kubernetes observes the actual state of the cluster.
  3. A controller continuously compares desired vs. actual state.
  4. If they differ, the controller takes action to reconcile them.
  5. Repeat forever.

This “control loop” (or “reconciliation loop”) pattern is used everywhere in Kubernetes — it's not one feature, it's the architectural philosophy. Once this clicks, most of Kubernetes' behavior becomes predictable.

2.2 Cluster architecture (the "what exists")

A Kubernetes cluster = a set of machines (nodes), split into two roles:

Control Plane (the brain) — makes global decisions, doesn't run your app containers:

Worker Nodes (the muscle) — where your actual application runs:

2.3 The object model (the "nouns" of Kubernetes)

Everything in Kubernetes is an object described in YAML/JSON, stored in etcd. Learn these in this order, smallest to largest:

Object What it is Theory / purpose
Pod The smallest deployable unit. One or more tightly-coupled containers sharing network/storage. Containers are never scheduled directly — pods are the atomic unit Kubernetes schedules.
ReplicaSet Ensures N copies of a pod are always running. A direct implementation of the control-loop idea for pod count.
Deployment Manages ReplicaSets; handles rolling updates and rollbacks. You almost always use Deployments instead of raw Pods/ReplicaSets — it's the standard way to run stateless apps.
Service A stable network identity (IP/DNS name) in front of a changing set of pods. Pods are mortal — they get replaced and get new IPs. Services solve “how do I reliably reach my app” despite that churn.
ConfigMap / Secret Externalized configuration and sensitive data. Keeps configuration out of container images, following the “build once, configure per environment” principle.
Namespace A way to partition one cluster into virtual sub-clusters. Multi-team/multi-environment isolation without separate physical clusters.
Volume / PersistentVolume (PV) / PersistentVolumeClaim (PVC) Storage that can outlive a pod. Pods are ephemeral; PV/PVC decouples “storage that exists” from “app that requests storage.”
StatefulSet Like a Deployment, but for apps needing stable identity/storage (databases, queues). Solves ordering, stable network names, and stable storage per replica — things stateless Deployments don't guarantee.
DaemonSet Ensures a pod runs on every (or selected) node. Used for node-level agents: log collectors, monitoring agents, network plugins.
Ingress Rules for routing external HTTP(S) traffic into Services. Gives you host/path-based routing, TLS termination, etc., at the cluster edge.

2.4 Labels, selectors, and the "loose coupling" theory

Kubernetes objects don't reference each other by hard IDs — they use labels (key-value tags) and selectors (queries over labels). A Service doesn't say “send traffic to pod-123”; it says “send traffic to any pod labeled app: frontend.” This loose coupling is why pods can be destroyed and recreated constantly without breaking anything pointing at them.

2.5 Networking theory (the model, not the implementation)

Kubernetes assumes a flat network model with these rules:

This is called the Kubernetes networking model, and it's implementation-agnostic — a plugin (CNI: Container Network Interface) fulfills these guarantees underneath. You don't need to master CNI internals early, but knowing this model exists explains why Services and DNS “just work” across nodes.


3. HOW — Learning Path and Hands-On Practice

Theory sticks when paired with doing. Suggested order:

Phase 1 — Prerequisites (if shaky)

Phase 2 — Local cluster setup

Use a lightweight local cluster (don't start with cloud — remove billing/complexity while learning):

Phase 3 — Core hands-on exercises (in order)

  1. Run a single Pod imperatively (kubectl run), inspect it (kubectl describe, kubectl logs).
  2. Write a Pod YAML manifest by hand, kubectl apply -f, and delete/recreate it to see the lifecycle.
  3. Create a Deployment; scale it up/down; kill a pod manually and watch it get recreated (this is where the control-loop theory becomes visible).
  4. Expose the Deployment with a Service (ClusterIP, then NodePort) and understand why the Pod IPs alone weren't enough.
  5. Add a ConfigMap and Secret; mount them into a pod as environment variables and as files.
  6. Perform a rolling update (change the image tag) and a rollback (kubectl rollout undo).
  7. Add a PVC to a pod and understand what happens to data when the pod is deleted vs. the PVC.
  8. Set up an Ingress controller (e.g., ingress-nginx) and route traffic by hostname/path.
  9. Explore resource requests/limits and watch what happens when you exceed them.
  10. Look at a StatefulSet example (e.g., a small database) to see stable naming/storage in action.

Phase 4 — Operational literacy

Phase 5 — Beyond the basics


4. Suggested Mental Model to Keep Reinforcing

Every time you learn a new Kubernetes object, ask three questions:

  1. What desired state am I declaring?
  2. What actual state is being observed and compared against it?
  3. What controller is reconciling the difference?

If you can answer those for Deployments, Services, PVCs, and HPAs, you understand Kubernetes' actual design — not just its API surface. Almost every “advanced” feature (operators, custom resources, autoscalers) is the same control-loop pattern applied to a new kind of desired state.


5. Quick Reference: Why → What → How Summary

Term Question it answers
Why Why can't containers alone manage a distributed system reliably?
What What are the building blocks (Pods, Deployments, Services, etc.) and what theory (control loops, loose coupling) underlies them?
How How do you actually run, expose, configure, and operate an app on a cluster?

Keep coming back to this table as you go deeper — it's easy to get lost in YAML details and lose sight of the underlying “why.”