CKA prep, by exam domain · Lesson 2 of 12 · about 50 minutes

A practice cluster: three machines with kubeadm

Turn the three practice machines into a real Kubernetes cluster with kubeadm, the tool the exam's curriculum names: create the control plane, give kubectl its kubeconfig, install Calico for pod networking, join two workers, and watch the scheduler place your first pods.

Exam domain: Cluster architecture, installation and configuration · 25% of the exam

By the end you'll know

  • Where the control plane lives, and what kubeadm init really builds
  • How to read kubeadm init output, phase by phase
  • Why kubectl needs the admin kubeconfig, and what happens when the order slips
  • Why a new cluster is NotReady until a pod network is installed
  • How to join workers, and why the join token is a password
  • How the scheduler places pods, and why it never moves them afterwards
  • Which objects belong to a namespace, and which belong to the whole cluster

Before you start

  • You need: Lesson 1 done: three machines from vagrant up, and the terminal setup on cp1 (the k alias, Tab completion, $do), plus the web.yaml you generated there.
  • The practice folder: git clone https://github.com/Kwamib/cka-practice.git
  • The output below is from a real run on November 23, 2026, between about 10:50pm and 11:20pm in New York, on an Apple silicon Mac. Your IP addresses, names and times will differ.

Every lesson after this one runs on the cluster you build here. Building it is also exam practice: installing and configuring a cluster with kubeadm is part of the Cluster Architecture domain, worth 25% of the score. So practice both halves: finishing a cluster that's half set up, and adding a worker to one that's running.

Where the control plane goes

Your three machines get three jobs:

OUTPUT
Your computer
└── VMware Fusion (or VirtualBox)
    ├── cp1      ← the control plane: the cluster's brain
    ├── worker1  ← runs your apps' pods
    └── worker2  ← runs your apps' pods

cp1 is short for control plane 1. kubeadm init installs the four control plane parts on it:

  • API server: the front door. Every kubectl command talks to it.
  • etcd: the database that holds the entire state of the cluster.
  • Scheduler: decides which node each new pod runs on.
  • Controller manager: keeps things matching what you asked for, like a Deployment's replica count.

Each one runs as a static pod: kubeadm writes its YAML file into /etc/kubernetes/manifests/ on cp1, and cp1's own kubelet starts it, with no API server involved. That's how the API server can run as a pod at all: something has to start it before there's an API to ask. It's also why a broken control plane gets fixed by editing those files on cp1, which Lesson 3 does.

The workers get none of this. They only run the kubelet and containerd, and kubeadm join connects them to cp1's API server. That's the usual shape of a small kubeadm cluster: one control plane node plus workers.

Check the address first

(cp1)

Log in first, and wait for the prompt before you type anything else:

BASH
vagrant ssh cp1

Then:

BASH
ip -4 addr show eth0
  • ip addr show eth0: shows the addresses on the network card eth0.
  • -4: IPv4 addresses only.
OUTPUT
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    altname enp2s0
    altname ens160
    inet 192.168.34.154/24 metric 100 brd 192.168.34.255 scope global dynamic eth0
       valid_lft 1393sec preferred_lft 1393sec

That inet line is the address the API server will use. Note it down. In a moment, kubeadm init creates certificates that are only valid for this address.

dynamic and valid_lft mean the address came from DHCP (Dynamic Host Configuration Protocol), the service that hands out addresses on a network. VMware and VirtualBox normally give each machine the same address after vagrant halt and vagrant up. But if cp1 ever comes back with a different one, its certificates won't match and the cluster stops working. So make this the first command of every session. A brand-new machine from vagrant destroy and vagrant up gets a new address, which is fine, because you build a new cluster on it anyway.

Create the control plane

(cp1)

BASH
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 2>&1 | tee ~/init.log
  • kubeadm init: turns this machine into a control plane node.
  • --pod-network-cidr=10.244.0.0/16: the range of addresses pods will get. CIDR (Classless Inter-Domain Routing) notation means 10.244.0.0 through 10.244.255.255, about 65,000 addresses. It must not overlap your machines' own network (192.168.34.0/24 here), and the network plugin has to use the same range. Calico reads it from the cluster, as you'll see.
  • 2>&1 | tee ~/init.log: shows everything on screen and keeps a copy in init.log. Init output is long, and you'll want to read it again.

It takes a minute or two, most of it downloading images. Here's the output, in its phases:

OUTPUT
I1124 03:52:45.195048    8625 version.go:260] remote version is much newer: v1.37.2; falling back to: stable-1.36
[init] Using Kubernetes version: v1.36.6
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] apiserver serving cert is signed for DNS names [cp1 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.34.154]
...
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "super-admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[kubelet-start] Starting the kubelet
[kubelet-check] The kubelet is healthy after 267.831µs
[control-plane-check] kube-scheduler is healthy after 2.510774ms
[control-plane-check] kube-controller-manager is healthy after 2.755647ms
[control-plane-check] kube-apiserver is healthy after 1.00107168s
[mark-control-plane] Marking the node cp1 as control-plane by adding the taints [node-role.kubernetes.io/control-plane:NoSchedule]
[bootstrap-token] Using token: TOKEN
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

Read it top to bottom once. Every phase is a place a cluster can break, so it's worth knowing what each one does:

  • remote version is much newer: v1.37.2; falling back to: stable-1.36: kubeadm looked up the newest Kubernetes release online and found v1.37.2. A v1.36 kubeadm only installs v1.36, so it used the newest v1.36 patch. That's not an error. It's the version gap Lesson 5 closes with a real upgrade.
  • [preflight]: checks the machine first: swap off, required ports free, a container runtime running. Most failed inits stop here, with a clear message.
  • [certs]: creates the cluster's own certificate authority (CA) and a certificate for every part, all in /etc/kubernetes/pki/. Look at the API server's line: it's valid for the name cp1, the internal name kubernetes.default, the Service address 10.96.0.1, and 192.168.34.154. That last one is why the address check matters.
  • [kubeconfig]: writes a kubeconfig for each part that talks to the API server. admin.conf is the one you'll use.
  • [etcd] and [control-plane]: write the four static pod files into /etc/kubernetes/manifests/.
  • [kubelet-start] and the checks: start the kubelet, which finds those files and starts the four pods, then wait until each one answers.
  • [mark-control-plane]: adds a taint to cp1. A taint keeps pods off a node unless they have a matching toleration. This one keeps your apps off the control plane. You'll see its effect later in this lesson.
  • [bootstrap-token]: creates a token the workers use to join.
  • [addons]: installs CoreDNS (the cluster's DNS server) and kube-proxy (which makes Services work on every node).

The join token is a password

The end of the init output prints a full kubeadm join command with a token and a hash. Anyone with that token who can reach your API server can add their own machine to your cluster for the next 24 hours, and a machine that joins can run pods and read some of the cluster's data. Don't paste it into chats, tickets or screenshots. If it gets out, delete it (kubeadm token delete, later in this lesson). You never need to save it: you can make a fresh join command any time.

Give kubectl the admin kubeconfig

(cp1)

kubectl still doesn't know this cluster exists. The init output tells you how to fix that:

BASH
mkdir -p ~/.kube
sudo cp /etc/kubernetes/admin.conf ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
  • mkdir -p ~/.kube: creates the folder kubectl looks in. -p means no error if it already exists.
  • sudo cp ...: copies the admin kubeconfig there. It needs sudo because only root can read /etc/kubernetes/admin.conf.
  • sudo chown $(id -u):$(id -g): gives the copy to you. $(id -u) and $(id -g) are replaced with your user and group numbers, so kubectl can read the file without sudo.

This is why Lesson 1's localhost:8080 error matters. With no kubeconfig, kubectl tries localhost:8080, a default that nothing listens on. On my first try I skipped the kubeadm init line and ran this block straight after the terminal setup:

OUTPUT
cp: cannot stat '/etc/kubernetes/admin.conf': No such file or directory
chown: cannot access '/home/vagrant/.kube/config': No such file or directory
The connection to the server localhost:8080 was refused - did you specify the right host or port?

Read the errors in order and they tell the story: admin.conf doesn't exist, so nothing was copied, so kubectl has no kubeconfig and falls back to localhost:8080. The fix wasn't anything in this block. It was the step before it. ls ~/init.log would have shown it too: no log means kubeadm init never ran. When a command fails because a file is missing, ask which step was supposed to create that file.

Why not export KUBECONFIG?

The init output offers export KUBECONFIG=/etc/kubernetes/admin.conf for the root user. It works, but only in that one shell, and only as root. Copying the file to ~/.kube/config works every time you log in, as your normal user. On a machine someone else set up, check whether ~/.kube/config already exists before copying anything.

NotReady, and why

(cp1)

BASH
k get nodes
k get pods -n kube-system
  • -n kube-system: shows the kube-system namespace, where Kubernetes' own pods run.
OUTPUT
NAME   STATUS     ROLES           AGE     VERSION
cp1    NotReady   control-plane   2m47s   v1.36.6

NAME                          READY   STATUS    RESTARTS   AGE
coredns-589f44dc88-2bbmv      0/1     Pending   0          2m59s
coredns-589f44dc88-hqh4q      0/1     Pending   0          2m59s
etcd-cp1                      1/1     Running   0          3m7s
kube-apiserver-cp1            1/1     Running   0          3m7s
kube-controller-manager-cp1   1/1     Running   0          3m7s
kube-proxy-9f7bq              1/1     Running   0          2m59s
kube-scheduler-cp1            1/1     Running   0          3m7s

This is exactly what a new kubeadm cluster should look like:

  • The four control plane pods end in -cp1. Static pods are named after their node. That's a quick way to spot them in any cluster.
  • cp1 is NotReady because there's no pod network yet. The kubelet won't report a node ready until a CNI (Container Network Interface) plugin is installed. kubeadm doesn't install one, because there are many to choose from.
  • CoreDNS is Pending for the same reason. CoreDNS pods need a pod IP address, which only a network plugin can give them, and while the node isn't ready the scheduler holds them back.
  • kube-proxy is already Running, because it uses the node's own network (host networking), not the pod network.

When nodes are NotReady and CoreDNS is Pending on a fresh cluster, the first question is always: is a network plugin installed?

Install the pod network

(cp1)

This track uses Calico, because it enforces NetworkPolicy, which Lesson 8 needs. (Flannel, another common choice, doesn't.) Calico v3.32 is the release made for Kubernetes v1.36:

BASH
k apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.32.1/manifests/calico.yaml
  • apply -f: creates everything in a file. -f takes a URL as well as a local file, so kubectl downloads the manifest and applies it in one step.
A building with no hallways. Before Calico, every room in the building exists, but there are no hallways between them. The rooms (pods) can't be reached, so nobody moves in. The network plugin builds the hallways and gives every room an address. That's why nothing on the network side works until it's in.

The output is long. Here are the parts worth knowing:

OUTPUT
serviceaccount/calico-node created
customresourcedefinition.apiextensions.k8s.io/ippools.crd.projectcalico.org created
Warning: unrecognized format "cidr"
customresourcedefinition.apiextensions.k8s.io/networkpolicies.crd.projectcalico.org created
...
clusterrole.rbac.authorization.k8s.io/calico-node created
clusterrolebinding.rbac.authorization.k8s.io/calico-node created
daemonset.apps/calico-node created
deployment.apps/calico-kube-controllers created
  • 23 CRDs (Custom Resource Definitions): 22 of Calico's own object types, like ippools, plus clusternetworkpolicies from the Kubernetes network policy project. A CRD teaches the API server a new kind of object. Lesson 7 covers them.
  • RBAC (Role-Based Access Control) objects: the permissions Calico needs. Lesson 6 covers these.
  • A DaemonSet, calico-node: one copy on every node, now and on every node that joins later. This is what builds the network on each machine.
  • A Deployment, calico-kube-controllers: one copy, which keeps Calico's records in step with the cluster.
  • Warning: unrecognized format "cidr": harmless. One of Calico's CRDs uses a validation format the API server doesn't know, so it skips that one check. Every line still says created.

Calico read the pod range you gave kubeadm init from the cluster, so you didn't edit anything. Watch it start:

BASH
k get pods -n kube-system -w
  • -w (watch): keeps running and prints a new line whenever a pod changes. Press Ctrl+C to stop watching. That only stops the command, not the pods.
OUTPUT
NAME                                       READY   STATUS              RESTARTS   AGE
calico-kube-controllers-58f68d56d9-cnbgx   0/1     ContainerCreating   0          22s
calico-node-hkbbs                          0/1     Running             0          22s
coredns-589f44dc88-2bbmv                   0/1     ContainerCreating   0          5m32s
...
calico-node-hkbbs                          1/1     Running             0          22s
coredns-589f44dc88-hqh4q                   0/1     Running             0          5m33s
coredns-589f44dc88-2bbmv                   1/1     Running             0          5m34s
coredns-589f44dc88-hqh4q                   1/1     Running             0          5m34s
calico-kube-controllers-58f68d56d9-cnbgx   1/1     Running             0          26s

Read it in order. calico-node became ready first. Within a second, the CoreDNS pods that had waited five and a half minutes were created and running. 0/1 Running, then 1/1 Running, is a container that started, then passed its readiness check a moment later. Running means the container is up. 1/1 means it's ready for traffic.

BASH
k get nodes
OUTPUT
NAME   STATUS   ROLES           AGE     VERSION
cp1    Ready    control-plane   6m46s   v1.36.6

One working node. Now add the workers.

Join the workers

(cp1)

Make a fresh join command right when you need it:

BASH
sudo kubeadm token create --print-join-command
  • token create: makes a new bootstrap token, valid for 24 hours.
  • --print-join-command: prints the complete join command with the token and hash filled in.
  • sudo: kubeadm reads /etc/kubernetes/admin.conf to talk to the cluster.
OUTPUT
kubeadm join 192.168.34.154:6443 --token TOKEN --discovery-token-ca-cert-hash sha256:HASH

It has two secrets-looking values, and they do different jobs:

  • The token proves to cp1 that the new machine is allowed to join. That's the password part.
  • The hash proves to the new machine that it's talking to the real cp1. It's a fingerprint of the cluster's CA certificate, so it's the same every time you run this. Only the token changes.

This command is also how you add a node a day later. The token from kubeadm init lasts 24 hours, so after that, the join command in the init output no longer works. token create --print-join-command is the fix, every time.

(worker1)

Open a second terminal on your computer, go to the practice folder, and log in to the worker. Wait for the vagrant@worker1:~$ prompt before pasting, or the join runs on your own computer instead (the pasted-block trap from Lesson 1).

BASH
vagrant ssh worker1

Then type sudo , paste the join command, and press Enter. It runs its own preflight checks, then ends by saying the node has joined the cluster. Do the same on worker2, in a third terminal. The same join command works on both.

(cp1)

BASH
k get nodes -o wide
  • -o wide: adds columns: each node's IP address, operating system, kernel and container runtime.
OUTPUT
NAME      STATUS     ROLES           AGE     VERSION   INTERNAL-IP      EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION             CONTAINER-RUNTIME
cp1       Ready      control-plane   9m24s   v1.36.6   192.168.34.154   <none>        Ubuntu 24.04.3 LTS   6.8.0-86-generic (arm64)   containerd://2.2.1
worker1   NotReady   <none>          6s      v1.36.6   192.168.34.155   <none>        Ubuntu 24.04.3 LTS   6.8.0-86-generic (arm64)   containerd://2.2.1

A new worker is NotReady for about 30 seconds, while the calico-node DaemonSet starts a copy on it. Run it again and it turns Ready. Once worker2 joins too:

OUTPUT
NAME      STATUS   ROLES           AGE     VERSION
cp1       Ready    control-plane   27m     v1.36.6
worker1   Ready    <none>          17m     v1.36.6
worker2   Ready    <none>          2m28s   v1.36.6

ROLES shows <none> for workers. That's normal: the column only shows node-role labels, and kubeadm only adds one to the control plane.

Delete tokens you're done with

(cp1)

Once the workers have joined, nothing needs a join token. Clean up:

BASH
sudo kubeadm token list
sudo kubeadm token delete TOKEN-1 TOKEN-2
sudo kubeadm token list
  • token list: shows every bootstrap token and when it expires.
  • token delete: takes one or more tokens, separated by spaces. The full token or only the part before the dot both work.
OUTPUT
TOKEN                     TTL         EXPIRES                USAGES                   DESCRIPTION
TOKEN-1                   23h         2026-11-25T04:17:12Z   authentication,signing   <none>
TOKEN-2                   23h         2026-11-25T04:01:44Z   authentication,signing   <none>

bootstrap token "abc123" deleted
bootstrap token "def456" deleted

(The token values here are placeholders. delete names each token by the part before the dot, its ID.)

I'd made two tokens that evening, one before each worker joined, and both were still valid. Every token create adds a token. None replaces the last one. The second token list should print only its header line.

A small thing that happened along the way: I typed sudo kubeadmin token delete ... and got kubeadmin: command not found. It's kubeadm, with no "in". Under exam pressure, that typo costs a minute. Type kubead and press Tab instead.

Run something on it

(cp1)

Apply the web.yaml you generated in Lesson 1, before any cluster existed:

BASH
k apply -f web.yaml
k get pods
OUTPUT
deployment.apps/web created

NAME                   READY   STATUS              RESTARTS   AGE
web-7887448d46-7xh5n   0/1     ContainerCreating   0          8s

Run k get pods again after a few seconds:

OUTPUT
NAME                   READY   STATUS    RESTARTS   AGE
web-7887448d46-7xh5n   1/1     Running   0          53s

The same file that apply rejected in Lesson 1, with no cluster to validate it, now just works. But where is the pod running?

BASH
k get pods -o wide
  • -o wide on pods adds the pod's IP address and the node it runs on.

When I applied it, worker2 hadn't joined yet, so the NODE column said worker1. Why worker1? It was the only choice. cp1 has the control-plane:NoSchedule taint from kubeadm init, and the web pod has no toleration for it. worker2 didn't exist yet. The scheduler writes its decision down, and you can read it:

BASH
k describe pod -l app=web
  • describe: shows everything about an object, with an Events list at the bottom.
  • -l app=web: short for --selector. Picks pods by label instead of by name. k create deploy web gave its pods the label app=web, so you don't have to type the generated name.

The first line under Events reads like Successfully assigned default/web-... to worker1. When a pod is stuck in Pending, that same Events list says why, for example 0/2 nodes are available: 1 node(s) had untolerated taint. Lesson 4 is built around reading those messages.

The scheduler decides once

With worker2 Ready, I scaled up:

BASH
k scale deploy web --replicas=8
k get pods -o wide
  • scale --replicas=8: changes how many copies the Deployment keeps.
OUTPUT
NAME                   READY   STATUS    RESTARTS   AGE     IP               NODE
web-558f679c7b-5lkm6   1/1     Running   0          6m2s    10.244.235.135   worker1
web-558f679c7b-7zrhz   1/1     Running   0          6m29s   10.244.235.133   worker1
web-558f679c7b-8gpdr   1/1     Running   0          12s     10.244.189.66    worker2
web-558f679c7b-hw92d   1/1     Running   0          6m2s    10.244.235.136   worker1
web-558f679c7b-m5p4z   1/1     Running   0          6m2s    10.244.235.137   worker1
web-558f679c7b-pxxlw   1/1     Running   0          12s     10.244.189.65    worker2
web-558f679c7b-qpxm2   1/1     Running   0          6m29s   10.244.235.132   worker1
web-558f679c7b-wsrnw   1/1     Running   0          6m28s   10.244.235.134   worker1

Six pods on worker1 and two on worker2. That's not a bug. Four things are going on:

  • The six on worker1 were all created before worker2 joined. The scheduler places a pod once, when it's created, using the nodes that exist at that moment. After that, a pod stays on its node until it's deleted. Kubernetes never rebalances running pods by itself.
  • The two newest pods went to worker2, because once it existed, the scheduler preferred the emptier node.
  • Each node has its own block of pod addresses. Pods on worker1 got 10.244.235.x, and pods on worker2 got 10.244.189.x. Calico splits your 10.244.0.0/16 into small blocks (64 addresses each, by default) and gives each node its own, so it always knows which node a pod address lives on.
  • The names changed from web-7887448d46-... to web-558f679c7b-.... The middle part is the ReplicaSet's hash. In between, I ran k rollout restart deploy web, which creates a new ReplicaSet, so every pod after it carries the new hash. Deployment, ReplicaSet, pods: each one creates the next.

Then I scaled back down:

BASH
k scale deploy web --replicas=1
k get pods -o wide
OUTPUT
NAME                   READY   STATUS    RESTARTS   AGE    IP              NODE
web-558f679c7b-8gpdr   1/1     Running   0          2m8s   10.244.189.66   worker2

The pod that survived is on worker2, even though worker1 held six of the eight. When a ReplicaSet scales down, it removes pods from the most crowded node first. Spreading happens when pods are created, and evening out happens when they're removed. If you need pods spread a particular way on purpose, that's Lesson 10.

Cluster-wide or namespaced

One thing I tried along the way:

BASH
k get nodes -A
  • -A: short for --all-namespaces.

It printed the same list as k get nodes, because nodes don't belong to any namespace. Some objects live inside a namespace: pods, Deployments, Services, ConfigMaps. Others belong to the whole cluster: nodes, namespaces themselves, PersistentVolumes, ClusterRoles. -n and -A mean nothing for cluster-wide objects. To check any type:

BASH
k api-resources --namespaced=false
  • api-resources: lists every object type the API server knows, including Calico's new CRDs.
  • --namespaced=false: only the cluster-wide ones. --namespaced=true shows the others.

This matters for RBAC in Lesson 6: a Role can only grant access inside one namespace, so permission to list nodes needs a ClusterRole.

How the drills work

Each drill is a task to do from a blank terminal. Try it first, without looking. Then open "Show the fast way" to compare your commands, and read the notes under them: they cover the part people usually get wrong. Repeat a drill a few days later until you can do it cold, because the exam leaves little time to look things up.

The drills

A new node will join the cluster. Load the kernel modules and set the network settings kubeadm needs so they survive a reboot, and turn swap off.

Show the fast way
BASH
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF
sudo sysctl --system

sudo swapoff -a
sudo sed -i '/ swap / s/^/#/' /etc/fstab

lsmod | grep -E 'overlay|br_netfilter'
sysctl net.ipv4.ip_forward net.bridge.bridge-nf-call-iptables

"Survive a reboot" is the part people miss. modprobe and sysctl -w only last until the next restart. The files in /etc/modules-load.d/ and /etc/sysctl.d/ make the settings permanent, and sysctl --system loads every file now. The sed line comments out the swap entry in /etc/fstab, so swap stays off after a reboot. The last two lines check the result: both modules listed, both values = 1. You don't need to memorize the two files: the Kubernetes docs page "Container Runtimes" has them, ready to copy.

A new cluster's nodes are NotReady. Install a network plugin that enforces NetworkPolicy, using the cluster's pod range.

Show the fast way
BASH
k get cm kubeadm-config -n kube-system -o yaml | grep podSubnet
k apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.32.1/manifests/calico.yaml
k get pods -n kube-system -w
k get nodes

Pick the plugin first. Calico and Cilium enforce NetworkPolicy. Flannel doesn't: a policy on a Flannel cluster is accepted and then silently ignored, so choosing Flannel fails this task even though everything looks fine. The first line finds the pod range kubeadm was given (podSubnet), and the manifest install reads it on its own. If the task gives Calico's operator install instead (tigera-operator.yaml plus custom-resources.yaml), download the second file and check that its cidr: matches before you create it. Use k create -f for the operator file, as Calico's docs do: its CRDs are too large for apply.

The token from kubeadm init has expired. Add a new worker to the cluster.

Show the fast way
BASH
# on the control plane
sudo kubeadm token create --print-join-command
# on the worker, as root
sudo kubeadm join CP-ADDRESS:6443 --token TOKEN --discovery-token-ca-cert-hash sha256:HASH
# back on the control plane
k get nodes -w

The new node turns Ready once the network plugin's DaemonSet pod is running on it, usually within a minute.

List the cluster's bootstrap tokens and delete all of them.

Show the fast way
BASH
sudo kubeadm token list
sudo kubeadm token delete TOKEN-1 TOKEN-2
sudo kubeadm token list

token delete takes several tokens at once, and either the full token or the part before the dot. An empty list (header only) means no machine can join until you create a new token.

Find which node each pod of the Deployment web runs on, and why the scheduler put the first one there.

Show the fast way
BASH
k get pods -l app=web -o wide
k describe pod -l app=web | grep -A3 Events

-o wide adds the NODE column. grep -A3 Events prints the Events line and the three after it, where the scheduler's Successfully assigned ... to NODE appears. If a pod is Pending, the same place says which rule ruled each node out.

On exam day

  • Install tasks give you the details. A task might name the pod range or the network plugin. Use exactly what it says, not what you used at home.
  • "Supports NetworkPolicy" rules out Flannel. If a task asks for a network plugin that enforces NetworkPolicy, pick Calico or Cilium.
  • Read kubeadm init errors from the [preflight] line. Most failures stop there and say which check failed: swap on, a port in use, or no container runtime.
  • NotReady right after an install usually means no network plugin, or its pod isn't running yet on that node. Check k get pods -n kube-system -o wide before anything else.
  • Remember where you are. Joins run on the worker, as root. Token commands run on the control plane. Look at the prompt before you paste.

Clean up

Nothing to delete: you'll use this cluster in every lesson. When you're done for the day:

(Your machine)

BASH
exit
vagrant halt
  • exit: leaves the machine you're logged in to. Do it in each terminal.
  • vagrant halt: shuts all three machines down, keeping the cluster on them.

Next session, run vagrant up, log in to cp1, and run ip -4 addr show eth0 before anything else. If the address still matches the one in init.log, k get nodes should show all three nodes Ready within a minute or two.

In real life

  • Real clusters have more than one control plane node, usually three, behind a load balancer, so losing one machine doesn't take the API down. kubeadm init has a --control-plane-endpoint flag for that address. A practice cluster like this one keeps it to one.
  • Real nodes get fixed addresses, from a DHCP reservation or static configuration, for exactly the reason in "Check the address first."
  • Managed services do all of this for you. Amazon EKS (Elastic Kubernetes Service), Azure AKS (Azure Kubernetes Service) and Google GKE (Google Kubernetes Engine) run the control plane and pick the network plugin. You may never run kubeadm init at work. The CKA still expects it, because the parts you built here are the parts that break.
  • Join tokens are handled like any other secret. Automated setups create a short-lived token right before a join and delete it after, the same habit as this lesson.

Spot the problem

Work out what's wrong before you read the explanation.

"kubectl works, but nothing starts." Someone runs kubeadm init, copies the kubeconfig, and deploys an app. k get nodes shows the node NotReady, and every pod, including CoreDNS, sits in Pending. They suspect the scheduler. What's really going on? No network plugin is installed. Without one, the node never reports ready, and the scheduler won't place pods that need the pod network. The control plane pods run only because they're static pods on the host's own network. Install the plugin and the node turns Ready within a minute.

"The join command doesn't work anymore." A teammate saved the join command from kubeadm init in a notes file. Two days later, they run it on a new worker and it fails to authenticate. What happened, and what's the fix? Bootstrap tokens expire after 24 hours by default, so the saved token is dead. (Keeping it in a notes file was also a risk while it lasted.) The fix is to run kubeadm token create --print-join-command on the control plane and use its output right away. The hash part of the old command was still right, because the CA never changed. Only the token had expired.

"Everything is on one node." A cluster has two workers, but all six pods of a Deployment run on worker1, and worker2 has none. Both nodes are Ready and neither has a taint. Is something broken? Probably not: the pods were likely created before worker2 joined, or while it was NotReady. The scheduler places each pod once and never moves it. k rollout restart deploy NAME replaces the pods, and the new ones get spread across both workers.

Keep this

ToUse
Create a control planesudo kubeadm init --pod-network-cidr=10.244.0.0/16
Set up kubectl for your usermkdir -p ~/.kube, copy /etc/kubernetes/admin.conf to ~/.kube/config, then chown it
Find the control plane's pod files/etc/kubernetes/manifests/
Find the cluster's certificates/etc/kubernetes/pki/
Install the pod networkk apply -f the plugin's manifest URL
Get a join commandsudo kubeadm token create --print-join-command
Join a workersudo kubeadm join ... on the worker
Remove join tokenssudo kubeadm token list, then sudo kubeadm token delete TOKEN
See which node a pod is onk get pods -o wide
See why it went therek describe pod NAME, then read Events
Pick objects by label-l key=value (short for --selector)
List cluster-wide object typesk api-resources --namespaced=false

Where you are now

You have a real three-node cluster on v1.36, built with the tools the curriculum names: a control plane created by kubeadm init, Calico for the pod network, and two workers joined with a fresh token that you then deleted. You can read kubeadm init output phase by phase, you know why a new cluster is NotReady until the network plugin arrives, and you've watched the scheduler place pods once and leave them there. Lesson 3 starts breaking this cluster on purpose, beginning with its nodes and control plane.

Check yourself

  1. Right after kubeadm init, cp1 is NotReady and both CoreDNS pods are Pending, while etcd, the API server and kube-proxy are Running. What's missing?

  2. You need to change one flag on the API server of a kubeadm cluster. What do you edit?

  3. You need to add a worker to a cluster created three days ago. What do you run on the control plane first?

  4. In a kubeadm join command, which part stops working after 24 hours?

  5. worker2 joined after all of web's pods were already running on worker1. Both workers are Ready, with no taints. What happens to web's pods?

  6. Why does k get nodes -A print exactly the same list as k get nodes?

Key terms

  • kubeadm: the official tool for creating a cluster (init), adding nodes (join) and upgrading them.
  • Static pod: a pod the kubelet runs straight from a file in /etc/kubernetes/manifests/, without the API server. The control plane runs this way.
  • Admin kubeconfig: /etc/kubernetes/admin.conf, the kubeconfig kubeadm init creates with full control of the cluster.
  • CNI (Container Network Interface): the standard that network plugins like Calico, Cilium and Flannel follow to give pods addresses and connect them.
  • Pod network CIDR: the range of addresses pods get, set with --pod-network-cidr.
  • DaemonSet: runs one copy of a pod on every node, including nodes that join later.
  • CRD (Custom Resource Definition): adds a new kind of object to the API server.
  • Taint and toleration: a taint keeps pods off a node unless a pod has a matching toleration.
  • Bootstrap token: the short-lived token a new node uses to join the cluster. Treat it as a password.
  • CA (certificate authority): the certificate the cluster uses to sign and trust all its other certificates.
  • Label selector: a filter like -l app=web that picks objects by their labels.
  • Cluster-wide object: an object that doesn't belong to a namespace, like a node or a PersistentVolume.

Go deeper