Kubernetes: the basics

Lesson 01 · 12 min

What Kubernetes solves: cluster, control plane, nodes and kubectl

You describe the desired state in YAML, and the cluster brings reality in line with it.

12 minLesson 1 of 5Practice includedAsk AI on any point

Docker can run a container on one machine. But production has many machines, containers crash, servers reboot, traffic grows in the evening and drops at night. Something has to decide where to run a container, restart it after a crash, spread the traffic and roll out a new version without downtime. That is the job of an orchestrator, and Kubernetes (k8s for short) became the standard one.

AI

You can ask about this point«Lesson summary»

What exactly Kubernetes takes care of

  • Scheduling: picks a node with enough CPU and memory for the container.
  • Self healing: a container crashed or a node disappeared, and Kubernetes starts a replacement elsewhere.
  • Scaling: 3 copies of the app become 10 with one command or automatically.
  • Networking and load balancing: a stable address for a group of containers that keep changing.
  • Zero downtime updates: a new version rolls out gradually, and the old one can be restored.
  • Configuration and secrets: settings live separately from the image.
AI

You can ask about this rule«Kubernetes does not replace Docker»

AI

You can ask about this point«What exactly Kubernetes takes care of»

Cluster: control plane and nodes

A cluster has two parts. The control plane is the brain: it accepts commands, stores state and decides what should run where. Nodes (worker nodes) are the hands: ordinary virtual or physical machines where containers actually run.

  • kube-apiserver: the single entry point to the cluster. kubectl, controllers and nodes talk only to it.
  • etcd: a key value store holding the whole cluster state. Lose etcd without a backup and you lose the cluster.
  • kube-scheduler: picks a node for every new Pod.
  • kube-controller-manager: a set of controllers that keep comparing the desired state with the actual one in a loop and fix the difference.
  • On every node: kubelet (the agent that runs containers and reports on them), kube-proxy (network rules for Services) and a container runtime.
AI

You can ask about this rule«Managed cluster»

AI

You can ask about this point«Cluster: control plane and nodes»

The declarative approach

The core idea of Kubernetes: you do not say "start three containers", you say "I want three copies of this image running at all times". That is the desired state. Controllers keep comparing it with the actual state and fix the difference. This cycle is called the reconciliation loop. The desired state is written in YAML manifests and kept in git next to the code.

The simplest manifest: a Pod

Every object has four required parts: apiVersion (the API version the type lives in), kind (the object type), metadata (name, namespace, labels) and spec (what you want). Kubernetes also adds status: what actually exists.

AI

You can ask about this point«The declarative approach»

kubectl: how to talk to the cluster

Basic commands
AI

You can ask about this rule«apply, not create»

AI

You can ask about this point«kubectl: how to talk to the cluster»

Check

Lock it in before you move on

  1. 1. Where does Kubernetes store the state of the whole cluster?

  2. 2. What does the declarative approach mean in Kubernetes?

  3. 3. Which component runs containers on a specific node?

  4. 4. How is kubectl apply different from kubectl create?

PracticeSolve the lesson tasksA few short tasks in the editor. Check your code right away and see where it goes wrong.Start practice