Kubernetes (often written K8s) runs containers across a fleet of machines and keeps them running the way you described. You tell it "I want 3 copies of this API, reachable on this name, with this much memory", and it schedules them, restarts them when they crash, replaces them when a machine dies, and rolls out new versions without downtime. This lesson explains the parts of a cluster and how they work together, which is the foundation for everything else in this course.
In simple words
- Kubernetes: a system that runs your containers across many machines and keeps them running. You say what you want, and it starts, restarts and spreads the containers for you.
- Cluster: a group of machines (nodes) that Kubernetes manages as one big computer.
- Control plane: the brain of the cluster. It stores the desired state, decides where pods run and keeps checking that reality matches.
- Node: one worker machine (a VM or server) that actually runs your containers.
- Declarative model: you describe the end result in YAML ("3 copies of this app") instead of giving step-by-step commands, and Kubernetes works out how to get there.
- kubectl: the command-line tool you use to talk to the cluster.
Why Kubernetes exists
Docker runs containers on one machine. Real systems need dozens of services across many machines, and someone has to answer:
| Question | Without Kubernetes | With Kubernetes |
|---|---|---|
| Which machine runs this container? | You decide, by hand | The scheduler decides |
| A container crashed at 3 a.m. | Someone gets paged | Restarted automatically |
| A whole server died | Manual recovery | Pods recreated on other nodes |
| Deploy a new version | Scripts, downtime | Rolling update, instant rollback |
| How do services find each other? | Hard-coded IPs | Service names and DNS |
| Traffic spike | Add servers by hand | Autoscaling |
The declarative model
The single most important idea: you declare desired state; Kubernetes continuously makes actual state match it.
apiVersion: apps/v1kind: Deploymentmetadata: name: webspec: replicas: 3 selector: matchLabels: { app: web } template: metadata: labels: { app: web } spec: containers: - name: nginx image: nginx:1.27 ports: - containerPort: 80You do not say "start a container on server 2". You say "there should be 3 web pods", and controllers work in a loop, forever, to keep it true. Delete a pod by hand and a new one appears seconds later. This is called reconciliation.
The parts of a cluster
A cluster has a control plane (the brain) and worker nodes (where your apps run).
Control plane
| Component | Job |
|---|---|
| kube-apiserver | The front door. Every request from kubectl, controllers and nodes goes through it. Handles authentication, authorization and validation |
| etcd | A distributed key-value database holding the entire cluster state. If etcd is lost without a backup, the cluster is lost |
| kube-scheduler | Assigns new pods to nodes based on resources, rules and spreading |
| kube-controller-manager | Runs the built-in controllers: Deployments, ReplicaSets, nodes, jobs, endpoints and more |
| cloud-controller-manager | Talks to the cloud: creates load balancers, attaches node info (on EKS, AKS, GKE) |
On managed services such as Amazon EKS, Azure AKS and Google GKE, the cloud runs the control plane for you. You only see the API endpoint.
Worker nodes
| Component | Job |
|---|---|
| kubelet | Agent on every node. Watches the API for pods assigned to its node, starts them, runs health checks, reports status |
| Container runtime | containerd or CRI-O, which actually pulls images and runs containers |
| kube-proxy | Programs iptables or IPVS rules so Service IPs reach the right pods (some CNIs such as Cilium replace it) |
| CNI plugin | Gives every pod an IP and connects pods across nodes (VPC CNI on EKS, Calico, Cilium) |
Add-ons you will meet in every cluster
CoreDNS (service names), metrics-server (CPU and memory usage), an ingress controller (HTTP routing), and usually logging and monitoring agents.
What happens when you run kubectl apply
The animation at the top of this lesson walks through it. In words:
- kubectl sends your YAML to the API server over HTTPS.
- The API server authenticates you, checks RBAC permissions, runs admission checks, and stores the object in etcd.
- The Deployment controller notices the new Deployment and creates a ReplicaSet, which creates 3 Pod objects (with no node yet).
- The scheduler notices unscheduled pods and assigns each to a node.
- The kubelet on each chosen node notices its new pod and tells containerd to pull the image and start the container.
- The kubelet reports status back; the pod shows
Running.
Notice nobody calls anybody directly: every component watches the API server and reacts. That design is why Kubernetes is so resilient and extensible.
Talking to the cluster
In the practice terminal:
kubectl cluster-infokubectl get nodeskubectl get pods -n kube-systemNAME STATUS ROLES AGE VERSIONlab-control Ready control-plane 3d v1.36.2lab-worker-1 Ready <none> 3d v1.36.2lab-worker-2 Ready <none> 3d v1.36.2kube-system is where cluster components such as CoreDNS and kube-proxy run as pods.
Key objects at a glance
| Object | Purpose | Lesson |
|---|---|---|
| Pod | One or more containers that run together | 3 |
| Deployment / ReplicaSet | Keep N copies running, roll out new versions | 4 |
| Service | Stable name and IP for a set of pods | 5 |
| Namespace | Divide a cluster into areas | 6 |
| ConfigMap / Secret | Configuration and credentials | 7 |
| PersistentVolumeClaim | Storage that survives pods | 8 |
| Ingress | HTTP routing from outside | 9 |
Real-world scenario
An e-commerce company ran 40 services on hand-managed VMs. Every Black Friday, engineers added servers by hand and stayed up watching dashboards. On EKS, each service is a Deployment with an autoscaler; nodes are added automatically when pods do not fit; failed pods restart on their own; and deploys are a Git commit. The same team now spends the night of the sale watching graphs instead of firefighting.
Common mistakes
- Treating pods like servers: logging into them to fix things. Fix the YAML and let Kubernetes replace them.
- Thinking Kubernetes is only for big companies. Managed services make small clusters easy, but it does add complexity; a single small app may be fine without it.
- Forgetting the control plane needs backups, especially etcd on self-managed clusters.
Practice
- Run
kubectl get nodesand identify the control-plane and worker nodes. - List the pods in
kube-systemand say what two of them do. - Explain the reconciliation loop to a friend using the Deployment example.
- Put the six steps of
kubectl applyin order without looking.
Cheat sheet
| Command | What it does |
|---|---|
kubectl cluster-info | API server address |
kubectl get nodes -o wide | Nodes, versions and IPs |
kubectl get pods -A | Pods in all namespaces |
kubectl api-resources | Every object type the cluster knows |
kubectl explain deployment.spec | Built-in field documentation |
Key takeaways
- You declare desired state; controllers reconcile reality to match it, forever.
- The control plane (API server, etcd, scheduler, controllers) decides; nodes (kubelet, runtime, kube-proxy, CNI) do.
- Everything goes through the API server, and every component works by watching it.