Skip to content
$ lynuxpro
← Kubernetes

LESSON 1 OF 25 · BEGINNER · 18 MIN

Kubernetes architecture

Free previewLesson 1 of the 2 free lessons in this Pro course.Unlock all 25

HOW IT WORKSWhat happens when you run kubectl apply

CONTROL PLANEWORKER NODEapplykubectlyou or CISchedulerpicks a nodeAPI serverfront dooretcdcluster databaseController mgrdesired = actualkubeletnode agentcontainerdruns containerskube-proxyService rulesPodyour app
1/6

You describe what you want in YAML and send it to the API server, the single front door of the cluster.

$ kubectl apply -f deployment.yaml

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:

QuestionWithout KubernetesWith Kubernetes
Which machine runs this container?You decide, by handThe scheduler decides
A container crashed at 3 a.m.Someone gets pagedRestarted automatically
A whole server diedManual recoveryPods recreated on other nodes
Deploy a new versionScripts, downtimeRolling update, instant rollback
How do services find each other?Hard-coded IPsService names and DNS
Traffic spikeAdd servers by handAutoscaling

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: 80
NORMALyamlutf-8 · 17L

You 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

ComponentJob
kube-apiserverThe front door. Every request from kubectl, controllers and nodes goes through it. Handles authentication, authorization and validation
etcdA distributed key-value database holding the entire cluster state. If etcd is lost without a backup, the cluster is lost
kube-schedulerAssigns new pods to nodes based on resources, rules and spreading
kube-controller-managerRuns the built-in controllers: Deployments, ReplicaSets, nodes, jobs, endpoints and more
cloud-controller-managerTalks 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

ComponentJob
kubeletAgent on every node. Watches the API for pods assigned to its node, starts them, runs health checks, reports status
Container runtimecontainerd or CRI-O, which actually pulls images and runs containers
kube-proxyPrograms iptables or IPVS rules so Service IPs reach the right pods (some CNIs such as Cilium replace it)
CNI pluginGives 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:

  1. kubectl sends your YAML to the API server over HTTPS.
  2. The API server authenticates you, checks RBAC permissions, runs admission checks, and stores the object in etcd.
  3. The Deployment controller notices the new Deployment and creates a ReplicaSet, which creates 3 Pod objects (with no node yet).
  4. The scheduler notices unscheduled pods and assigns each to a node.
  5. The kubelet on each chosen node notices its new pod and tells containerd to pull the image and start the container.
  6. 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-system
SHELLbashutf-8 · 3L
NAME           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.2
OUTPUTterminalutf-8 · 4L

kube-system is where cluster components such as CoreDNS and kube-proxy run as pods.

Key objects at a glance

ObjectPurposeLesson
PodOne or more containers that run together3
Deployment / ReplicaSetKeep N copies running, roll out new versions4
ServiceStable name and IP for a set of pods5
NamespaceDivide a cluster into areas6
ConfigMap / SecretConfiguration and credentials7
PersistentVolumeClaimStorage that survives pods8
IngressHTTP routing from outside9

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

  1. Run kubectl get nodes and identify the control-plane and worker nodes.
  2. List the pods in kube-system and say what two of them do.
  3. Explain the reconciliation loop to a friend using the Deployment example.
  4. Put the six steps of kubectl apply in order without looking.

Cheat sheet

CommandWhat it does
kubectl cluster-infoAPI server address
kubectl get nodes -o wideNodes, versions and IPs
kubectl get pods -APods in all namespaces
kubectl api-resourcesEvery object type the cluster knows
kubectl explain deployment.specBuilt-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.