Skip to content
CNPE · Chapter 2 of 22 Day 0: The terrain – a kubeadm cluster like in the exam

Day 0: The terrain – a kubeadm cluster like in the exam

Goal: Build a Kubernetes 1.37 cluster with kubeadm from three fresh VMs, set up Cilium as the network, metrics-server and storage, and start Gitea as the Git server for the platform · Duration: approx. 75 min · Prerequisite: three VMs with Ubuntu 24.04 (sizes in the table), internet access

Briefing

  • In the CNPE exam you work for two hours on Kubernetes clusters built with kubeadm: command line, kubectl with the alias k, plus web interfaces such as Argo CD or Grafana. This course builds exactly that kind of terrain and sticks with it for all 18 days.
  • You build an internal platform: teams get namespaces with limits, deliver via Git, order environments through an API, are monitored and protected by policies. Each day adds one building block.
  • The terrain is three VMs. cp1 is the control plane and your workstation, worker1 and worker2 carry the workloads.
VM IP Role In the lab
cp1 172.16.0.126 Control plane, workstation 4 vCPU, 12 GB
worker1 172.16.0.228 Worker 2 vCPU, 8 GB
worker2 172.16.0.83 Worker 2 vCPU, 8 GB

Your addresses are different; use them wherever 172.16.0.… appears. Less than 8 GB on the workers is enough for Days 0 to 4; from Argo Rollouts, Prometheus and Tekton onwards it gets tight.

What gradually grows on the terrain:

Building block Tool Day
Git server and container registry Gitea 0, 6
Tenants, limits, permissions Namespaces, Quotas, RBAC 1
GitOps Argo CD, ApplicationSet 3, 4
Progressive delivery Argo Rollouts 5
CI in the cluster Tekton 6
Platform APIs CRDs, Crossplane 7, 8
Monitoring Prometheus, Grafana, OpenCost 10–12
Policies and supply chain Kyverno, Trivy, cosign 13, 14
mTLS Linkerd 15

Drill 1: Access to the three VMs

You work from your machine via SSH. A dedicated key for the lab keeps it separate from your other accounts.

# on your machine
# generate a new key of type Ed25519
#   -t ed25519     key type (short, fast, today's standard)
#   -f ~/.ssh/cnpe file name: private key ~/.ssh/cnpe, public key ~/.ssh/cnpe.pub
#   -C cnpe-labor  comment, shows up later in authorized_keys
ssh-keygen -t ed25519 -f ~/.ssh/cnpe -C cnpe-labor

Expected (abridged, you may leave the passphrase empty):

Generating public/private ed25519 key pair.
Your identification has been saved in /home/du/.ssh/cnpe
Your public key has been saved in /home/du/.ssh/cnpe.pub
# on your machine
# copy the public key to each VM (asks once for the password of ubuntu)
#   -i ~/.ssh/cnpe.pub  which key is transferred
ssh-copy-id -i ~/.ssh/cnpe.pub [email protected]
ssh-copy-id -i ~/.ssh/cnpe.pub [email protected]
ssh-copy-id -i ~/.ssh/cnpe.pub [email protected]
# test: hostname of each VM, without a password
#   -i ~/.ssh/cnpe  log in with this key
for ip in 126 228 83; do ssh -i ~/.ssh/cnpe [email protected].$ip hostname; done

Expected:

cp1
worker1
worker2

If your VMs have different names, set them now: sudo hostnamectl set-hostname cp1 on the first VM, and likewise on the others. kubeadm uses the hostname as the node name.

Save your progress? Sign up for free

Drill 2: Preparing the nodes

Kubernetes needs three things from every node: two kernel modules, three network settings and a container runtime. The following commands run on all three VMs.

# on cp1, worker1 and worker2
# load modules at boot: overlay (container file system), br_netfilter (bridge traffic
# through iptables, so that Services work)
printf 'overlay\nbr_netfilter\n' | sudo tee /etc/modules-load.d/k8s.conf
# and load them right away, without a reboot
sudo modprobe overlay
sudo modprobe br_netfilter
# kernel settings: pass bridge traffic to iptables (IPv4 and IPv6) and forward packets
printf 'net.bridge.bridge-nf-call-iptables = 1\nnet.bridge.bridge-nf-call-ip6tables = 1\nnet.ipv4.ip_forward = 1\n' \
  | sudo tee /etc/sysctl.d/k8s.conf
# reload all sysctl files, show only the two most important lines
sudo sysctl --system | grep -E '^net\.(bridge.bridge-nf-call-iptables|ipv4.ip_forward)'
# swap must be off: no line = no swap
swapon --show | wc -l

Expected (abridged):

net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
0

If swapon shows anything other than 0, turn swap off with sudo swapoff -a and remove the swap line from /etc/fstab.

As the runtime you use containerd from the Ubuntu packages. You need to change two settings:

# on cp1, worker1 and worker2
# install containerd (Ubuntu 24.04 ships 2.2)
sudo apt-get install -y -qq containerd
# generate the default configuration and store it as a file
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null
# 1. manage cgroups via systemd – the same method the kubelet uses
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
# 2. the same pause image as kubeadm 1.37 (containerd ships 3.10.1)
sudo sed -i 's#registry.k8s.io/pause:3.10.1#registry.k8s.io/pause:3.10.2#' /etc/containerd/config.toml
# restart so that containerd reads the file
sudo systemctl restart containerd
# check: version, both changes, service is running
containerd --version
grep -E 'SystemdCgroup|sandbox = ' /etc/containerd/config.toml
systemctl is-active containerd

Expected:

containerd github.com/containerd/containerd/v2 2.2.1
      sandbox = 'registry.k8s.io/pause:3.10.2'
            SystemdCgroup = true
active

Why SystemdCgroup: the kubelet has long used the systemd driver for cgroups. If kubelet and containerd manage the cgroups in two different ways, pods run at first but become unstable under load – an error you only notice days later.

Save your progress? Sign up for free

Drill 3: kubeadm, kubelet and kubectl

The three programs come from the package archive of the Kubernetes project. Each minor version has its own archive; you add the one for 1.37. Again on all three VMs:

# on cp1, worker1 and worker2
# directory for package source keys
sudo mkdir -p -m 755 /etc/apt/keyrings
# fetch the archive's signing key and convert it to apt's binary format
#   --dearmor  ASCII key → binary   -o  target file
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.37/deb/Release.key \
  | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
# add the package source, trusted only with this key (signed-by)
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.37/deb/ /' \
  | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update -qq
# which versions are available?
apt-cache madison kubeadm | head -3

Expected:

   kubeadm | 1.37.3-1.1 | https://pkgs.k8s.io/core:/stable:/v1.37/deb  Packages
   kubeadm | 1.37.2-1.1 | https://pkgs.k8s.io/core:/stable:/v1.37/deb  Packages
   kubeadm | 1.37.1-1.1 | https://pkgs.k8s.io/core:/stable:/v1.37/deb  Packages
# on cp1, worker1 and worker2
# install exactly this version (=version), all three the same
sudo apt-get install -y -qq kubelet=1.37.3-1.1 kubeadm=1.37.3-1.1 kubectl=1.37.3-1.1
# protect against automatic updates: you do an upgrade deliberately with kubeadm
sudo apt-mark hold kubelet kubeadm kubectl
kubeadm version -o short

Expected:

kubelet set on hold.
kubeadm set on hold.
kubectl set on hold.
v1.37.3

The kubelet now restarts in a loop – it has no configuration yet. That is how it should be; kubeadm writes it in the next drill.

Save your progress? Sign up for free

Drill 4: The control plane

# on cp1
# pre-pull the control plane images (saves waiting time during init)
sudo kubeadm config images pull --kubernetes-version v1.37.3
# set up the control plane
#   --kubernetes-version          fixed version instead of "latest"
#   --pod-network-cidr            address range of the pods; each node gets a /24 from it
#   --apiserver-advertise-address IP under which the API server is reachable
#   --node-name                   name of the node in the cluster
sudo kubeadm init --kubernetes-version v1.37.3 --pod-network-cidr 10.244.0.0/16 \
  --apiserver-advertise-address 172.16.0.126 --node-name cp1 | tee ~/init.log

Expected (abridged):

[config/images] Pulled registry.k8s.io/coredns/coredns:v1.14.6
[config/images] Pulled registry.k8s.io/pause:3.10.2
[config/images] Pulled registry.k8s.io/etcd:3.7.0-0
[init] Using Kubernetes version: v1.37.3
[preflight] Running pre-flight checks
...
Your Kubernetes control-plane has initialized successfully!
...
kubeadm join 172.16.0.126:6443 --token o3pn07.jmmk59xodzyxpirf \
    --discovery-token-ca-cert-hash sha256:bea2efd9a7686a06...

You will need the join command shortly; it is also in ~/init.log. Now your user gets access to the cluster, and you set up the shell as in the exam:

# on cp1
# copy the administrator's kubeconfig into your home directory and make it yours
mkdir -p ~/.kube
sudo cp /etc/kubernetes/admin.conf ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
# alias k and tab completion – in the exam both are already set up
echo 'alias k=kubectl' >> ~/.bashrc
echo 'source <(kubectl completion bash)' >> ~/.bashrc
echo 'complete -o default -F __start_kubectl k' >> ~/.bashrc
source ~/.bashrc
k get nodes

Expected:

NAME   STATUS     ROLES           AGE   VERSION
cp1    NotReady   control-plane   6s    v1.37.3

NotReady is expected: there is no pod network yet.

Save your progress? Sign up for free

Drill 5: Cilium as the pod network

Without a CNI plugin, no pods start outside the host network. You install Cilium with Helm, the package manager you will use from now on to install almost every tool.

# on cp1
# architecture of the VM (amd64 or arm64) and Helm version
ARCH=$(dpkg --print-architecture); V=v4.3.2
# download archive and checksum, verify the checksum
cd /tmp
curl -sSfLO https://get.helm.sh/helm-$V-linux-$ARCH.tar.gz
curl -sSfLO https://get.helm.sh/helm-$V-linux-$ARCH.tar.gz.sha256sum
sha256sum -c helm-$V-linux-$ARCH.tar.gz.sha256sum
# unpack and install only the binary (-m 755: executable for everyone)
tar xzf helm-$V-linux-$ARCH.tar.gz
sudo install -m 755 linux-$ARCH/helm /usr/local/bin/helm
cd ~
helm version --short

Expected:

helm-v4.3.2-linux-amd64.tar.gz: OK
v4.3.2+g8346aaa
# on cp1
# register Cilium's chart repository and load the index
helm repo add cilium https://helm.cilium.io/
helm repo update
# install Cilium
#   --version 1.20.5          fixed chart version
#   --namespace kube-system   that is where the network components run
#   ipam.mode=kubernetes      take pod addresses from the /24 that kubeadm gives each node
#   operator.replicas=1       one operator is enough in the lab (default: 2)
helm install cilium cilium/cilium --version 1.20.5 --namespace kube-system \
  --set ipam.mode=kubernetes --set operator.replicas=1
# wait until the agent is running on every node
k -n kube-system rollout status ds/cilium --timeout=300s
k get nodes

Expected (abridged):

STATUS: deployed
...
daemon set "cilium" successfully rolled out
NAME   STATUS   ROLES           AGE    VERSION
cp1    Ready    control-plane   100s   v1.37.3

Save your progress? Sign up for free

Drill 6: The workers join

The token from init is valid for 24 hours. It is safer to have a fresh join command generated:

# on cp1
# create a new token and print the complete join command
kubeadm token create --print-join-command

Expected (your values are different):

kubeadm join 172.16.0.126:6443 --token zy8jx0.d8h125eqt5ye29wh --discovery-token-ca-cert-hash sha256:bea2efd9a7686a06...

You run the command with sudo on the workers and append the node name:

# on worker1 (on worker2 the same with --node-name worker2)
#   --token                         short-lived secret for joining
#   --discovery-token-ca-cert-hash  fingerprint of the cluster CA: the worker checks that it is talking to the
#                                   right API server
#   --node-name                     name in the cluster
sudo kubeadm join 172.16.0.126:6443 --token zy8jx0.d8h125eqt5ye29wh \
  --discovery-token-ca-cert-hash sha256:bea2efd9... --node-name worker1

Expected (end):

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
# on cp1
# wait until all three nodes are ready
k wait --for=condition=Ready node --all --timeout=180s
# nodes with capacity and the pod network each one got
k get nodes -o custom-columns=NAME:.metadata.name,CPU:.status.capacity.cpu,MEM:.status.capacity.memory,PODCIDR:.spec.podCIDR

Expected:

node/cp1 condition met
node/worker1 condition met
node/worker2 condition met
NAME      CPU   MEM          PODCIDR
cp1       4     12248228Ki   10.244.0.0/24
worker1   2     8132452Ki    10.244.1.0/24
worker2   2     8132460Ki    10.244.2.0/24

Save your progress? Sign up for free

Drill 7: Metrics and storage

Every fresh kubeadm cluster lacks two things: metrics-server (for k top and the HPA on Day 2) and a StorageClass, so that PersistentVolumeClaims get storage automatically.

# on cp1
helm repo add metrics-server https://kubernetes-sigs.github.io/metrics-server/
helm repo update
# install metrics-server
#   image.tag=v0.9.1                   latest version (the chart still ships 0.9.0)
#   args={--kubelet-insecure-tls}      the kubeadm kubelets have self-signed
#                                      certificates; do not verify them in the lab
helm install metrics-server metrics-server/metrics-server --version 3.14.0 -n kube-system \
  --set image.tag=v0.9.1 --set 'args={--kubelet-insecure-tls}'
# local-path-provisioner: creates volumes as directories on the node
k apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.37/deploy/local-path-storage.yaml
# mark as the default StorageClass: PVCs without storageClassName end up here
k patch storageclass local-path \
  -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
k -n kube-system rollout status deploy/metrics-server --timeout=180s

After about half a minute, metrics-server delivers its first values:

# on cp1
k top nodes
k get storageclass

Expected (numbers vary):

NAME      CPU(cores)   CPU(%)   MEMORY(bytes)   MEMORY(%)
cp1       473m         11%      1145Mi          9%
worker1   163m         8%       528Mi           6%
worker2   155m         7%       548Mi           6%
NAME                   PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
local-path (default)   rancher.io/local-path   Delete          WaitForFirstConsumer   false                  63s

WaitForFirstConsumer means: the volume is only created when a pod uses it – on the node where the pod runs.

Save your progress? Sign up for free

Drill 8: Gitea – the platform’s Git

GitOps needs a Git. Gitea runs in the cluster and brings a web interface, pull requests, webhooks and a container registry. For the lab, SQLite is enough as the database; you switch off the chart’s high-availability components (PostgreSQL HA, Valkey cluster).

# on cp1
mkdir -p ~/cnpe/tag00 && cd ~/cnpe/tag00
cat > gitea-werte.yaml <<'EOF'
postgresql-ha:
  enabled: false          # no PostgreSQL HA of its own ...
valkey-cluster:
  enabled: false          # ... and no Valkey cluster
persistence:
  enabled: true
  size: 5Gi               # repos and SQLite file on one PVC
strategy:
  type: Recreate          # stop the old pod first, then start the new one (see below)
service:
  http:
    type: NodePort        # web and Git reachable via every node ...
    nodePort: 30300       # ... on a fixed port
gitea:
  admin:                  # first user, administrator
    username: platform
    password: platform-lab-123
    email: [email protected]
  config:                 # sections of Gitea's app.ini
    server:
      ROOT_URL: http://172.16.0.126:30300/   # address in links and clone URLs
      DOMAIN: 172.16.0.126
    database:
      DB_TYPE: sqlite3
    session:
      PROVIDER: memory    # sessions, cache and queues in memory or local,
    cache:                # because there is no Valkey
      ADAPTER: memory
    queue:
      TYPE: level
EOF
helm repo add gitea-charts https://dl.gitea.com/charts/
helm repo update
#   -n gitea --create-namespace   own namespace, gets created
#   -f gitea-werte.yaml           the values from above
helm install gitea gitea-charts/gitea --version 12.7.0 -n gitea --create-namespace -f gitea-werte.yaml
k -n gitea rollout status deploy/gitea --timeout=400s
# the REST API answers with the version
curl -s http://172.16.0.126:30300/api/v1/version

Expected (abridged):

STATUS: deployed
...
deployment "gitea" successfully rolled out
{"version":"1.27.0"}

Why Recreate: with SQLite and the local queue (queue.TYPE: level), Gitea holds locks on files in the volume. With the default RollingUpdate, the new pod starts while the old one is still running, and dies in a loop with unable to lock level db at /data/queues/common. One volume, one process – that applies to every application with a file-based database.

Open http://172.16.0.126:30300 in your browser and log in as platform. The password is in plain text in a file – fine for a lab; the Enterprise Note explains how to do it properly.

Now the first repository, in which the whole platform will be described from Day 3 on. You create it via the API – the exam may ask for something like this too:

# on cp1
sudo apt-get install -y -qq git jq
# create the repository "plattform"
#   -u platform:…      authentication (Basic Auth)
#   auto_init: true    right away with README and first commit
curl -s -u platform:platform-lab-123 -H 'Content-Type: application/json' \
  -d '{"name":"plattform","auto_init":true,"default_branch":"main"}' \
  http://172.16.0.126:30300/api/v1/user/repos | jq -r .clone_url
# set up Git: name and e-mail for commits, store credentials
git config --global user.name 'Platform Team'
git config --global user.email [email protected]
git config --global credential.helper store
printf 'http://platform:[email protected]%%3a30300\n' > ~/.git-credentials
chmod 600 ~/.git-credentials
# clone, create a folder, push back
cd ~/cnpe
git clone http://172.16.0.126:30300/platform/plattform.git
cd plattform
mkdir -p apps && echo '# Plattform-Repo' > apps/README.md
git add -A && git commit -qm 'Ordner apps' && git push -q
git log --oneline origin/main

Expected:

http://172.16.0.126:30300/platform/plattform.git
6b6be88 Ordner apps
144c323 Initial commit

Finally yq, which is preinstalled in the exam – with it you read and change YAML the way you do JSON with jq:

# on cp1
ARCH=$(dpkg --print-architecture)
sudo curl -sSfL -o /usr/local/bin/yq \
  https://github.com/mikefarah/yq/releases/download/v4.54.3/yq_linux_$ARCH
sudo chmod 755 /usr/local/bin/yq
yq --version

Expected:

yq (https://github.com/mikefarah/yq/) version v4.54.3

Save your progress? Sign up for free

Exercise: What runs where?

Time limit: 5 minutes.

  1. On which nodes do the two CoreDNS pods run?
  2. Which Helm releases exist in the cluster, with chart and app version?
  3. On which node is Gitea’s volume?

Solution

# on cp1
# 1: pods with label k8s-app=kube-dns, column NODE
k -n kube-system get pods -l k8s-app=kube-dns -o wide
# 2: all releases in all namespaces
helm list -A
# 3: Gitea pod and its node (local-path creates the volume where the pod started)
k -n gitea get pods -o wide

Expected (abridged, nodes may be distributed differently):

NAME                       READY   STATUS    RESTARTS   AGE     IP             NODE
coredns-559f6c778d-24kfr   1/1     Running   0          9m10s   10.244.0.241   cp1
coredns-559f6c778d-zs9xp   1/1     Running   0          9m10s   10.244.0.65    cp1
NAME            NAMESPACE   REVISION    ... STATUS      CHART                   APP VERSION
cilium          kube-system 1           ... deployed    cilium-1.20.5           1.20.5
gitea           gitea       1           ... deployed    gitea-12.7.0            1.27.0
metrics-server  kube-system 1           ... deployed    metrics-server-3.14.0   0.9.0
NAME                    READY   STATUS    RESTARTS   AGE     IP            NODE
gitea-88dc8f54c-fl9kz   1/1     Running   0          3m52s   10.244.2.29   worker2

The app version of metrics-server shows 0.9.0: Helm shows what is in the chart, not the image you overrode with image.tag. k -n kube-system get deploy metrics-server -o jsonpath='{.spec.template.spec.containers[0].image}' shows the truth.

Save your progress? Sign up for free

Challenge

Time limit: 10 minutes. A fourth node is to join in a week. How does it get a valid join command, and how do you see which tokens are currently valid and when they expire?

Solution

Tokens expire after 24 hours. On the day of joining, you generate a new one:

# on cp1
# valid tokens with remaining lifetime
kubeadm token list
# new token with its own lifetime, e.g. 2 hours (--ttl), including the join command
kubeadm token create --ttl 2h --print-join-command

Expected (abridged, your tokens are different):

TOKEN                     TTL         EXPIRES                USAGES                   DESCRIPTION
o3pn07.jmmk59xodzyxpirf   23h         2026-11-28T22:36:32Z   authentication,signing   The default bootstrap token generated by 'kubeadm init'.
zy8jx0.d8h125eqt5ye29wh   23h         2026-11-28T22:45:48Z   authentication,signing   <none>
kubeadm join 172.16.0.126:6443 --token wc6zmg.oncxfxyg1kgbtqwg --discovery-token-ca-cert-hash sha256:bea2efd9...

One token from init and one from Drill 6 are still valid. If you no longer need them, delete them with kubeadm token delete <token> – a valid token is a key to the cluster.

You do not need to recompute the CA hash – --print-join-command fills it in.

Save your progress? Sign up for free

Checkpoint

# on cp1
# three nodes, all Ready, all v1.37.3
k get nodes
# no pods that are not running (0)
k get pods -A --no-headers | grep -vc Running
# StorageClass exists (the "(default)" marker only shows in the list without a name)
k get storageclass local-path
# Gitea answers
curl -s http://172.16.0.126:30300/api/v1/version
# the repository has two commits
git -C ~/cnpe/plattform log --oneline | wc -l

Expected:

NAME      STATUS   ROLES           AGE   VERSION
cp1       Ready    control-plane   9m21s   v1.37.3
worker1   Ready    <none>          7m24s   v1.37.3
worker2   Ready    <none>          7m10s   v1.37.3
0
NAME         PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
local-path   rancher.io/local-path   Delete          WaitForFirstConsumer   false                  5m9s
{"version":"1.27.0"}
2

Interview Note

  • Why kubeadm and not k3s or a managed cluster? kubeadm shows every building block individually: runtime, kubelet, certificates, control plane as static pods, CNI. The CNPE exam runs on kubeadm clusters.
  • What happens if kubelet and containerd use different cgroup drivers? Two managers for the same resources – pods start but become unstable under pressure. Set both to systemd.
  • What is the CA hash for when joining? The new node uses it to check that it is talking to the real API server, not to an attacker on the network.

Enterprise Note

  • Several control plane nodes behind a fixed address (--control-plane-endpoint), etcd backed up; a single control plane node is a lab, not a platform.
  • Run Gitea with external PostgreSQL, Valkey and object storage; the administrator password from a Secret (gitea.admin.existingSecret), never in plain text in Helm values.
  • Git access for humans via SSO (OIDC), for tools via dedicated tokens with minimal permissions instead of Basic Auth with the admin account.
  • Hold package versions (apt-mark hold) and plan upgrades only via kubeadm upgrade – Day 2 practises the draining that every upgrade needs.

Contents

More