This is Chapter 1 of the Kubernetes Fundamentals series.
Nodes and clusters
- A node (sometimes called a minion) is a worker machine in Kubernetes - a collection of Pods runs on it.
- Multiple nodes together form a cluster.
- One node in that cluster is the master node - it watches over the worker nodes, orchestrates containers across them, and is where Kubernetes itself is installed.
The five components
Installing Kubernetes means installing five components. A mnemonic worth keeping: Api-server, Etcd, Kubelet, Controller, Scheduler:
| Component | What it does | Runs on |
|---|---|---|
| kube-apiserver | The frontend to the cluster - users, CLIs, and management tools all talk to it to interact with Kubernetes | Master node |
| etcd | Distributed, reliable key-value store holding all data used to manage the cluster | Master node |
| kubelet | Agent on each node that makes sure containers are running as expected | Worker node |
| Container runtime | The underlying software that actually runs containers, e.g. Docker | Worker node |
| Controller | The brain behind orchestration - watches for containers going down and spawns replacements | Master node |
| Scheduler | Distributes work (containers) across the available nodes | Master node |
How the pieces connect
kubectl / users
|
v
+------------------------------------+
| MASTER NODE |
| kube-apiserver - the entry point |
| etcd - cluster state |
| controller - watches & heals |
| scheduler - places Pods |
+------------------------------------+
|
v scheduler assigns a Pod to a node
+------------------------------------+
| WORKER NODE |
| kubelet - runs the Pod |
| container runtime - e.g. Docker |
| Pod(s) |
+------------------------------------+
Every arrow above only flows one way - the worker node never talks back to the master except through kube-apiserver, and nothing outside the master node ever reaches etcd, the controller, or the scheduler directly.
Pods
A Pod is a single instance of an application, and the smallest object in Kubernetes - a container is always encapsulated inside one, never run directly. Running more than one container in a Pod is a rare, advanced pattern; stick to a single container per Pod unless there’s a specific reason not to (a sidecar, for example).
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
namespace: dev
labels:
app: myapp
type: frontend
env: production
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 8080
resources:
requests:
memory: "4Gi"
cpu: 2
Chapter 2 covers creating and managing this object with kubectl.
Notes
- The master node is excluded from scheduling by default - a taint is applied to it automatically at cluster creation, covered in Chapter 5.
- Chapter 2 picks up from here with
kubectlitself and the imperative/declarative split for managing the Pod object shown above. - Next: Chapter 2 - kubectl and Pods.