By the end you'll know
- Where the control plane lives, and what
kubeadm initreally builds - How to read
kubeadm initoutput, phase by phase - Why kubectl needs the admin kubeconfig, and what happens when the order slips
- Why a new cluster is
NotReadyuntil 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 oncp1(thekalias, Tab completion,$do), plus theweb.yamlyou 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:
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
kubectlcommand 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:
vagrant ssh cp1
Then:
ip -4 addr show eth0
ip addr show eth0: shows the addresses on the network cardeth0.-4: IPv4 addresses only.
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)
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 means10.244.0.0through10.244.255.255, about 65,000 addresses. It must not overlap your machines' own network (192.168.34.0/24here), 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 ininit.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:
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 namecp1, the internal namekubernetes.default, the Service address10.96.0.1, and192.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.confis 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 tocp1. 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:
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.-pmeans no error if it already exists.sudo cp ...: copies the admin kubeconfig there. It needssudobecause 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 withoutsudo.
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:
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)
k get nodes
k get pods -n kube-system
-n kube-system: shows thekube-systemnamespace, where Kubernetes' own pods run.
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. cp1isNotReadybecause 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
Pendingfor 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:
k apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.32.1/manifests/calico.yaml
apply -f: creates everything in a file.-ftakes a URL as well as a local file, so kubectl downloads the manifest and applies it in one step.
The output is long. Here are the parts worth knowing:
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, plusclusternetworkpoliciesfrom 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 sayscreated.
Calico read the pod range you gave kubeadm init from the cluster, so you didn't edit anything. Watch it start:
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.
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.
k get nodes
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:
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.confto talk to the cluster.
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
cp1that 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).
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)
k get nodes -o wide
-o wide: adds columns: each node's IP address, operating system, kernel and container runtime.
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:
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:
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.
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:
k apply -f web.yaml
k get pods
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:
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?
k get pods -o wide
-o wideon 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:
k describe pod -l app=web
describe: shows everything about an object, with anEventslist at the bottom.-l app=web: short for--selector. Picks pods by label instead of by name.k create deploy webgave its pods the labelapp=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:
k scale deploy web --replicas=8
k get pods -o wide
scale --replicas=8: changes how many copies the Deployment keeps.
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 got10.244.189.x. Calico splits your10.244.0.0/16into 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-...toweb-558f679c7b-.... The middle part is the ReplicaSet's hash. In between, I rank 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:
k scale deploy web --replicas=1
k get pods -o wide
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:
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:
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=trueshows 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
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
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
# 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
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
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 initerrors from the[preflight]line. Most failures stop there and say which check failed: swap on, a port in use, or no container runtime. NotReadyright after an install usually means no network plugin, or its pod isn't running yet on that node. Checkk get pods -n kube-system -o widebefore 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)
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 inithas a--control-plane-endpointflag 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 initat 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
| To | Use |
|---|---|
| Create a control plane | sudo kubeadm init --pod-network-cidr=10.244.0.0/16 |
| Set up kubectl for your user | mkdir -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 network | k apply -f the plugin's manifest URL |
| Get a join command | sudo kubeadm token create --print-join-command |
| Join a worker | sudo kubeadm join ... on the worker |
| Remove join tokens | sudo kubeadm token list, then sudo kubeadm token delete TOKEN |
| See which node a pod is on | k get pods -o wide |
| See why it went there | k describe pod NAME, then read Events |
| Pick objects by label | -l key=value (short for --selector) |
| List cluster-wide object types | k 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
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?
You need to change one flag on the API server of a kubeadm cluster. What do you edit?
You need to add a worker to a cluster created three days ago. What do you run on the control plane first?
In a kubeadm join command, which part stops working after 24 hours?
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?
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 kubeconfigkubeadm initcreates 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=webthat 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
- Creating a cluster with kubeadm (opens in a new tab), the page this lesson follows.
- kubeadm token (opens in a new tab), the full reference for creating, listing and deleting tokens.
- Taints and tolerations (opens in a new tab), for the control plane taint and how to work with it.
- Calico's quickstart for kubeadm clusters (opens in a new tab), including the operator-based install many production clusters use.