Appendix C: Building the ost Cluster
Yourself
Goal: Three fresh VMs with Ubuntu 24.04 become the cluster
ostthat the whole book runs on: kubeadm v1.37.2 without kube-proxy, Cilium 1.20.5 with Hubble and Gateway API, metrics-server and the default StorageClasslocal-path. · Duration: approx. 75 min · Prerequisite: three VMs with Ubuntu 24.04, SSH access withsudo
Briefing
- Day 0 assumes a ready-made cluster. If you do not have one, you build it here – step by step, exactly the way the book was tested.
- Three roles:
cp1is the Control Plane and your workstation,worker1andworker2carry the workloads. All commands run as the userubuntu. - Cilium replaces kube-proxy with eBPF, assigns the Pod networks from 10.0.0.0/16 and tunnels traffic between the nodes via VXLAN.
- Two settings are specific to this course: Cilium does not rewrite
Service addresses inside the Pod (Day 0, Drill 2), and it brings the
GatewayClass
cilium(Day 10).
cp1 .126 worker1 .228 worker2 .83
Control Plane, kubectl, Worker Worker
helm, cilium, hubble
4 vCPU / 12 GB 2 vCPU / 4 GB 2 vCPU / 4 GB
|__________________________|________________________|
172.16.0.0/24 · Pods 10.0.0.0/16 (Cilium, VXLAN)
Services 10.96.0.0/12 · no kube-proxy
Replace the IPs with your own. The VMs do not need name resolution between each other, which is why IPs appear everywhere. The first line of every command block says where it runs. Steps 1 to 4 run on all three VMs.
| Component | Version |
|---|---|
| Kubernetes (kubeadm, kubelet, kubectl) | v1.37.2 |
| containerd / runc | 2.4.2 / 1.5.3 |
| Gateway API CRDs (standard channel) | v1.6.3 |
| Helm | v4.3.2 |
| Cilium (Helm chart) / cilium CLI / hubble CLI | 1.20.5 / v0.20.3 / v1.20.4 |
| metrics-server | v0.9.1 |
| local-path-provisioner | v0.0.37 |
All downloads detect the architecture
(dpkg --print-architecture). On a Mac with Apple Silicon
that is arm64 – the commands stay the same, only the output
shown here says amd64.
Step 1: Set the hostnames
kubeadm uses the hostname as the node name. The book expects
cp1, worker1 and worker2.
# on cp1
# set the hostname permanently – kubeadm uses it as the node name
sudo hostnamectl set-hostname cp1
# show the new name
hostnamectl hostname# on worker1
# set the hostname permanently
sudo hostnamectl set-hostname worker1
# show the new name
hostnamectl hostname# on worker2
# set the hostname permanently
sudo hostnamectl set-hostname worker2
# show the new name
hostnamectl hostnameExpected: the new name each time,
i.e. cp1, worker1 and
worker2.
Happened during testing: The lab VMs are provisioned with cloud-init (Proxmox). The new name survived a reboot; at boot, cloud-init only rewrote
/etc/hosts, with the old name in the127.0.1.1line. That does not matter for the cluster: it works with IPs, and systemd-resolved resolves the machine’s own name anyway.
Step 2: Prepare the kernel
# on cp1, worker1 and worker2
# load the modules overlay (container file system) and br_netfilter (bridge
# traffic passes through iptables) at every boot
printf 'overlay\nbr_netfilter\n' | sudo tee /etc/modules-load.d/k8s.conf
# load both modules right now, without a reboot
sudo modprobe overlay
sudo modprobe br_netfilter
# set kernel parameters permanently: forward packets, hand bridge traffic to iptables
cat <<'EOF' | sudo tee /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
# reload all sysctl files; --system includes /etc/sysctl.d/
sudo sysctl --system >/dev/null
# check the values
sysctl net.ipv4.ip_forward net.bridge.bridge-nf-call-iptables
# count active swap areas – by default the kubelet does not start with swap
swapon --show | wc -lExpected (shortened):
overlay
br_netfilter
...
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
0
If swapon shows anything: run
sudo swapoff -a and comment out the swap line in
/etc/fstab. Without ip_forward, no packet from
a Pod gets past the node.
Step 3: containerd and runc
Both straight from the project, each with a checksum:
# on cp1, worker1 and worker2
# downloads go to /tmp
cd /tmp
# containerd version and download address as variables
V=2.4.2
U=https://github.com/containerd/containerd/releases/download/v$V
# architecture of the VM: amd64 or arm64
ARCH=$(dpkg --print-architecture)
# fetch archive and checksum; -sS quiet but show errors, -L follow redirects,
# -O save under the file name from the URL
curl -sSLO $U/containerd-$V-linux-${ARCH}.tar.gz
curl -sSLO $U/containerd-$V-linux-${ARCH}.tar.gz.sha256sum
# verify the checksum – must report "OK"
sha256sum -c containerd-$V-linux-${ARCH}.tar.gz.sha256sum
# unpack to /usr/local (C = target directory, x = extract, z = gzip, f = file)
sudo tar Cxzf /usr/local containerd-$V-linux-${ARCH}.tar.gz
# put the project's systemd unit for this version in place
sudo mkdir -p /usr/local/lib/systemd/system
sudo curl -sSL -o /usr/local/lib/systemd/system/containerd.service \
https://raw.githubusercontent.com/containerd/containerd/v$V/containerd.service
# runc: the runtime containerd calls for every container
R=1.5.3
U=https://github.com/opencontainers/runc/releases/download/v$R
curl -sSLO $U/runc.${ARCH}
curl -sSLO $U/runc.sha256sum
# verify only the line for this architecture
grep " runc.${ARCH}$" runc.sha256sum | sha256sum -c
# copy to /usr/local/sbin as executable (mode 755)
sudo install -m 755 runc.${ARCH} /usr/local/sbin/runc
# check the version
runc --version | head -1Expected:
containerd-2.4.2-linux-amd64.tar.gz: OK
runc.amd64: OK
runc version 1.5.3
Generate the configuration and switch to the systemd cgroup driver (like the kubelet):
# on cp1, worker1 and worker2
# create the configuration directory
sudo mkdir -p /etc/containerd
# generate and save the full default configuration
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null
# manage cgroups via systemd – that is what the kubelet expects
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
# check the change (-n shows the line number)
grep -n SystemdCgroup /etc/containerd/config.toml
# make systemd aware of the new unit file
sudo systemctl daemon-reload
# start containerd now and at every boot
sudo systemctl enable --now containerd
# show the version of the running service
containerd --versionExpected:
89: SystemdCgroup = true
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → ...
containerd github.com/containerd/containerd/v2 v2.4.2 b7a25261e029...
Step 4: kubeadm, kubelet and kubectl
# on cp1, worker1 and worker2
# refresh the package lists
sudo apt-get update
# helper packages: HTTPS sources, CA certificates, curl, gpg for the key,
# jq to read JSON (needed on later days)
sudo apt-get install -y apt-transport-https ca-certificates curl gpg jq
# create the directory for package keys (-m 755: readable by everyone)
sudo mkdir -p -m 755 /etc/apt/keyrings
# fetch the signing key of the Kubernetes repo for v1.37 and convert it to binary
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; signed-by ties it to exactly this key
K=/etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=$K] https://pkgs.k8s.io/core:/stable:/v1.37/deb/ /" \
| sudo tee /etc/apt/sources.list.d/kubernetes.list
# load the package lists including the new source
sudo apt-get update
# show the available kubeadm versions (the two newest)
apt-cache madison kubeadm | head -2
# install exactly v1.37.2; cri-tools brings crictl for inspecting containers
sudo apt-get install -y kubelet=1.37.2-1.1 kubeadm=1.37.2-1.1 kubectl=1.37.2-1.1 \
cri-tools
# pin the versions – apt upgrade will not change them behind your back
sudo apt-mark hold kubelet kubeadm kubectl
# tell crictl where containerd listens (containers and images)
printf 'runtime-endpoint: unix:///run/containerd/containerd.sock\n' \
| sudo tee /etc/crictl.yaml
printf 'image-endpoint: unix:///run/containerd/containerd.sock\n' \
| sudo tee -a /etc/crictl.yaml
# check the versions; -o short prints only the number
kubeadm version -o short
sudo crictl versionExpected (shortened):
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
...
kubelet set on hold.
kubeadm set on hold.
kubectl set on hold.
...
v1.37.2
Version: 0.1.0
RuntimeName: containerd
RuntimeVersion: v2.4.2
RuntimeApiVersion: v1
Happened during testing: By the time this appendix was built, 1.37.3 had already been released and showed up at the top of
madison. The book stays on 1.37.2 – hence the version inapt-get installand thehold. The packagekubernetes-cnicomes along as a dependency; Cilium does not need its plugins, but they do no harm either.
Step 5: Control Plane without kube-proxy
From here on, only on cp1. A
--pod-network-cidr is missing on purpose: Cilium assigns
the Pod networks itself, and the kube-controller-manager should not
write a second, different allocation.
# on cp1
# set up the Control Plane in version v1.37.2
# --apiserver-advertise-address: the workers reach the API server at this IP
# --skip-phases=addon/kube-proxy: no kube-proxy, Cilium replaces it
sudo kubeadm init --kubernetes-version=v1.37.2 \
--apiserver-advertise-address=172.16.0.126 --skip-phases=addon/kube-proxy
# copy the admin credentials for the user ubuntu
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# the copy belongs to ubuntu, not root
sudo chown $(id -u):$(id -g) $HOME/.kube/config
# first look: one node, no Pod network yet
kubectl get nodes
# DaemonSets in kube-system – without kube-proxy there are none
kubectl -n kube-system get ds
# kubeadm records "no kube-proxy" in its configuration (-A1: one more line)
kubectl -n kube-system get cm kubeadm-config \
-o jsonpath='{.data.ClusterConfiguration}' | grep -A1 '^proxy'Expected (shortened):
Your Kubernetes control-plane has initialized successfully!
...
kubeadm join 172.16.0.126:6443 --token ... \
--discovery-token-ca-cert-hash sha256:...
NAME STATUS ROLES AGE VERSION
cp1 NotReady control-plane 4s v1.37.2
No resources found in kube-system namespace.
proxy:
disabled: true
NotReady is correct: without a CNI, no Pod gets an IP.
You do not need the kubeadm join line yet; step 8 generates
a fresh one. proxy.disabled: true makes sure that
kubeadm upgrade does not reinstall kube-proxy either.
Step 6: Gateway API CRDs
The Gateway API is not part of Kubernetes; its CRDs come separately. They go into the cluster before Cilium: the Cilium operator checks at startup whether they exist and only then enables its Gateway controller. If they came later, you would have to restart the operator and the agents. Linkerd needs the same CRDs from Day 1 on.
# on cp1
# release address of Gateway API v1.6.3 – the version Cilium 1.20.5 expects
GWAPI=https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.6.3
# apply the standard channel (also contains GRPCRoute, TLSRoute and TCPRoute);
# --server-side because the CRDs are too large for a normal apply
kubectl apply --server-side -f $GWAPI/standard-install.yaml
# list the installed Gateway API CRDs
kubectl get crd | grep gateway.networkingExpected (shortened):
customresourcedefinition.apiextensions.k8s.io/backendtlspolicies.gateway.networking.
k8s.io serverside-applied
...
validatingadmissionpolicybinding.admissionregistration.k8s.io/safe-upgrades.gateway.
networking.k8s.io serverside-applied
backendtlspolicies.gateway.networking.k8s.io Namespaced v1(storage) ...
gatewayclasses.gateway.networking.k8s.io Cluster v1(storage),v1beta1 ...
gateways.gateway.networking.k8s.io Namespaced v1(storage),v1beta1 ...
grpcroutes.gateway.networking.k8s.io Namespaced v1(storage) ...
httproutes.gateway.networking.k8s.io Namespaced v1(storage),v1beta1 ...
listenersets.gateway.networking.k8s.io Namespaced v1(storage) ...
referencegrants.gateway.networking.k8s.io Namespaced v1,v1beta1(storage) ...
tcproutes.gateway.networking.k8s.io Namespaced v1(storage) ...
tlsroutes.gateway.networking.k8s.io Namespaced v1(storage) ...
udproutes.gateway.networking.k8s.io Namespaced v1(storage) ...
Step 7: Helm, cilium CLI and hubble CLI
Three tools on cp1, all with checksums:
# on cp1
# downloads go to /tmp; detect the VM's architecture
cd /tmp
ARCH=$(dpkg --print-architecture)
# Helm v4.3.2: fetch archive and checksum, verify, unpack, install
H=v4.3.2
curl -sSLO https://get.helm.sh/helm-$H-linux-${ARCH}.tar.gz
curl -sSLO https://get.helm.sh/helm-$H-linux-${ARCH}.tar.gz.sha256sum
sha256sum -c helm-$H-linux-${ARCH}.tar.gz.sha256sum
tar xzf helm-$H-linux-${ARCH}.tar.gz
sudo install -m 755 linux-${ARCH}/helm /usr/local/bin/helm
# cilium CLI v0.20.3 (status, configuration, tests); --no-same-owner: files
# belong to root instead of the user ID stored in the archive
C=v0.20.3
U=https://github.com/cilium/cilium-cli/releases/download/$C
curl -sSLO $U/cilium-linux-${ARCH}.tar.gz
curl -sSLO $U/cilium-linux-${ARCH}.tar.gz.sha256sum
sha256sum -c cilium-linux-${ARCH}.tar.gz.sha256sum
sudo tar xzf cilium-linux-${ARCH}.tar.gz -C /usr/local/bin --no-same-owner
# hubble CLI v1.20.4 (read network flows)
HV=v1.20.4
U=https://github.com/cilium/hubble/releases/download/$HV
curl -sSLO $U/hubble-linux-${ARCH}.tar.gz
curl -sSLO $U/hubble-linux-${ARCH}.tar.gz.sha256sum
sha256sum -c hubble-linux-${ARCH}.tar.gz.sha256sum
sudo tar xzf hubble-linux-${ARCH}.tar.gz -C /usr/local/bin --no-same-owner
# tab completion for kubectl, helm, cilium and hubble in every new shell
cat <<'EOF' >> ~/.bashrc
source <(kubectl completion bash)
source <(helm completion bash)
source <(cilium completion bash)
source <(hubble completion bash)
EOF
# load the completion in this shell right away
source ~/.bashrc
# check the versions
helm version --short
cilium version --client
hubble version
# add Cilium's chart repository and load its index
helm repo add cilium https://helm.cilium.io/
helm repo update
# show the newest chart versions
helm search repo cilium/cilium --versions | head -3Expected (shortened):
helm-v4.3.2-linux-amd64.tar.gz: OK
cilium-linux-amd64.tar.gz: OK
hubble-linux-amd64.tar.gz: OK
v4.3.2+g8346aaa
cilium-cli: v0.20.3 compiled with go1.27.3 on linux/amd64
cilium image (default): v1.20.3
cilium image (stable): v1.20.5
hubble v1.20.4@HEAD-3e268bb compiled with go1.27.3 on linux/amd64
"cilium" has been added to your repositories
...
NAME CHART VERSION APP VERSION DESCRIPTION
cilium/cilium 1.20.5 1.20.5 eBPF-based Networking, Security, and ...
cilium/cilium 1.20.4 1.20.4 eBPF-based Networking, Security, and ...
On its own, the cilium CLI would install 1.20.3. That is why Cilium comes via Helm with a fixed version – just as it runs in production.
Step 8: Install Cilium
Without kube-proxy, nobody knows the API server’s Service IP 10.96.0.1 yet. That is why Cilium is given its real address:
# on cp1
# install Cilium 1.20.5 via Helm into kube-system:
# kubeProxyReplacement=true Services via eBPF instead of kube-proxy
# k8sServiceHost/k8sServicePort real address of the API server – without
# kube-proxy the Service IP 10.96.0.1 does not
# work yet
# ipam.mode=cluster-pool Cilium assigns the Pod networks itself …
# …PodCIDRList=10.0.0.0/16 … from this range …
# …MaskSize=24 … one /24 per node
# routingMode=tunnel, vxlan Pod traffic between nodes in a VXLAN tunnel
# hubble.enabled, relay.enabled flow observation plus cluster-wide relay
# operator.replicas=1 one operator is enough in the lab
# gatewayAPI.enabled=true Gateway controller and GatewayClass "cilium"
# socketLB.hostNamespaceOnly=true rewrite Service IPs only in the host, not in
# Pods – otherwise the Linkerd proxy only sees
# Pod IPs
helm install cilium cilium/cilium --version 1.20.5 -n kube-system \
--set kubeProxyReplacement=true \
--set k8sServiceHost=172.16.0.126 --set k8sServicePort=6443 \
--set ipam.mode=cluster-pool \
--set ipam.operator.clusterPoolIPv4PodCIDRList=10.0.0.0/16 \
--set ipam.operator.clusterPoolIPv4MaskSize=24 \
--set routingMode=tunnel --set tunnelProtocol=vxlan \
--set hubble.enabled=true --set hubble.relay.enabled=true \
--set operator.replicas=1 \
--set gatewayAPI.enabled=true \
--set socketLB.hostNamespaceOnly=true
# generate the join command for the workers (new token, valid for 24 hours)
kubeadm token create --print-join-commandExpected (shortened):
NAME: cilium
...
STATUS: deployed
REVISION: 1
...
You have successfully installed Cilium with Hubble Relay.
WARNINGS:
- WARNING: TLS is not enabled for the Hubble Relay server ...
Your release version is 1.20.5.
...
kubeadm join 172.16.0.126:6443 --token ... --discovery-token-ca-cert-hash sha256:...
Why 10.0.0.0/16? The chart default 10.0.0.0/8 would include the
Service network 10.96.0.0/12. A /16 with a /24 per node is enough for
256 nodes and does not overlap with west (10.42.0.0/16, Day
12). You accept the TLS warning about Hubble Relay in the lab. Token and
hash are credentials for the cluster – do not share them.
Step 9: Add the workers
The printed kubeadm join line runs with
sudo on both workers. Insert your token and your hash:
# on worker1 and worker2
# add the node to the cluster: API server address, token for authentication and
# hash of the CA certificate, so that the worker recognizes the right cluster
sudo kubeadm join 172.16.0.126:6443 --token <token> \
--discovery-token-ca-cert-hash sha256:<hash>Expected (shortened):
[preflight] Running pre-flight checks
...
W1126 21:24:24.052625 2681 configset.go:77] Warning: No kubeproxy.config.k8s.io/
v1alpha1 config is loaded. Continuing without it: configmaps "kube-proxy" is forbidden
...
This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.
The warning about kube-proxy is correct here: it does
not exist, on purpose.
Back on cp1:
# on cp1
# wait until all Cilium components are ready (gives up after 5 minutes)
cilium status --wait
# nodes with IP, operating system and container runtime (-o wide)
kubectl get nodes -o wide
# Pod networks that Cilium assigned to the nodes
kubectl get ciliumnodes \
-o custom-columns=NAME:.metadata.name,PODCIDRS:.spec.ipam.podCIDRsExpected (shortened):
/¯¯\
/¯¯\__/¯¯\ Cilium: OK
\__/¯¯\__/ Operator: OK
/¯¯\__/¯¯\ Envoy DaemonSet: OK
\__/¯¯\__/ Hubble Relay: OK
\__/ ClusterMesh: disabled
DaemonSet cilium Desired: 3, Ready: 3/3, Available: 3/3
DaemonSet cilium-envoy Desired: 3, Ready: 3/3, Available: 3/3
Deployment cilium-operator Desired: 1, Ready: 1/1, Available: 1/1
Deployment hubble-relay Desired: 1, Ready: 1/1, Available: 1/1
...
NAME STATUS ROLES AGE VERSION INTERNAL-IP ...
cp1 Ready control-plane 3m41s v1.37.2 172.16.0.126 ...
worker1 Ready <none> 2m19s v1.37.2 172.16.0.228 ...
worker2 Ready <none> 2m8s v1.37.2 172.16.0.83 ...
NAME PODCIDRS
cp1 [10.0.1.0/24]
worker1 [10.0.0.0/24]
worker2 [10.0.2.0/24]
Which node gets which /24 depends on whose Cilium agent asks first –
on your cluster cp1 may well have
10.0.0.0/24.
Warning:
cilium status --waitwhile onlycp1is in the cluster runs into a timeout after 5 minutes: Hubble Relay does not tolerate the Control Plane taint and staysPending. Add the workers first, then wait.
Now the two settings this course builds on:
# on cp1
# kube-proxy replacement active? We ask the Cilium agent itself
kubectl -n kube-system exec ds/cilium -c cilium-agent -- cilium-dbg status \
| grep KubeProxyReplacement
# socket load balancing: expected "false true" or "true true", never "true false"
kubectl -n kube-system get configmap cilium-config \
-o jsonpath='{.data.bpf-lb-sock} {.data.bpf-lb-sock-hostns-only}{"\n"}'
# GatewayClass created by the Cilium chart
kubectl get gatewayclass
# version of the Gateway API CRDs from their annotation
kubectl get crd httproutes.gateway.networking.k8s.io -o \
jsonpath='{.metadata.annotations.gateway\.networking\.k8s\.io/bundle-version}{"\n"}'Expected:
KubeProxyReplacement: True [eth0 172.16.0.126 ... (Direct Routing)]
false true
NAME CONTROLLER ACCEPTED AGE
cilium io.cilium/gateway-controller True 2m50s
v1.6.3
false true is exactly the value that Day 0 checks in
Drill 2.
Step 10: SSH from cp1 to the
workers
On Day 13, cp1 sets routes on the workers via
ssh. For that, cp1 needs its own key without a
passphrase:
# on cp1
# create a lab key without a passphrase: -t type, -N '' empty passphrase,
# -f file, -C comment in the public key
ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519 -C ubuntu@cp1Expected (shortened):
Your identification has been saved in /home/ubuntu/.ssh/id_ed25519
Your public key has been saved in /home/ubuntu/.ssh/id_ed25519.pub
ssh-copy-id does not help because the VMs do not allow
password logins. Your own machine, which reaches all VMs by key,
distributes the public key:
# on your machine
# read cp1's public key and append it to worker1's authorized_keys
ssh [email protected] cat .ssh/id_ed25519.pub \
| ssh [email protected] 'cat >> .ssh/authorized_keys'
# the same for worker2
ssh [email protected] cat .ssh/id_ed25519.pub \
| ssh [email protected] 'cat >> .ssh/authorized_keys'For Day 12, cp1 needs the same access to
west. If that VM already exists, append the key there the
same way
(ssh [email protected] 'cat >> .ssh/authorized_keys'
as the second part of the line); otherwise do it on Day 12.
Back on cp1:
# on cp1
# first contact: accept-new stores the host key without asking,
# a changed key would still be rejected
ssh -o StrictHostKeyChecking=accept-new [email protected] hostname
ssh -o StrictHostKeyChecking=accept-new [email protected] hostname
# crictl on a worker via sudo – count the Cilium agent containers
ssh 172.16.0.83 sudo crictl ps --name cilium-agent -q | wc -lExpected:
Warning: Permanently added '172.16.0.228' (ED25519) to the list of known hosts.
worker1
Warning: Permanently added '172.16.0.83' (ED25519) to the list of known hosts.
worker2
1
Step 11: metrics-server and local-path
metrics-server provides the numbers for kubectl top;
local-path-provisioner creates volumes as directories on the node.
Postgres in notes needs a volume from Day 0 on.
# on cp1
# metrics-server v0.9.1 – provides the numbers for kubectl top
M=https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.9.1
kubectl apply -f $M/components.yaml
# in the lab the kubelet certificates are self-signed: disable verification by
# appending an argument to the first container's list via JSON patch
kubectl -n kube-system patch deployment metrics-server --type=json -p \
'[{"op":"add","path":"/spec/template/spec/containers/0/args/-",
"value":"--kubelet-insecure-tls"}]'
# wait until the new version runs
kubectl -n kube-system rollout status deployment metrics-server
# local-path-provisioner v0.0.37: creates volumes as directories on the node
L=https://raw.githubusercontent.com/rancher/local-path-provisioner/v0.0.37
kubectl apply -f $L/deploy/local-path-storage.yaml
# make local-path the default StorageClass (annotation on the object)
kubectl patch storageclass local-path -p \
'{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
# check the result
kubectl get storageclassExpected (shortened):
serviceaccount/metrics-server created
...
deployment.apps/metrics-server patched
Waiting for deployment "metrics-server" rollout to finish: 1 old replicas are pending
termination...
deployment "metrics-server" successfully rolled out
namespace/local-path-storage created
...
storageclass.storage.k8s.io/local-path patched
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ...
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer ...
A short test with a throwaway Pod shows whether a volume really gets created:
# on cp1
# throwaway namespace for the test
kubectl create namespace speichertest
# PVC without storageClassName (so the default class) and a Pod that writes into it
cat <<'EOF' | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata: {name: daten, namespace: speichertest}
spec:
accessModes: [ReadWriteOnce]
resources: {requests: {storage: 1Gi}}
---
apiVersion: v1
kind: Pod
metadata: {name: schreiber, namespace: speichertest}
spec:
containers:
- name: c
image: docker.io/library/busybox:1.37
command: [sh, -c, 'echo gespeichert > /daten/test && sleep 3600']
volumeMounts: [{name: daten, mountPath: /daten}]
volumes: [{name: daten, persistentVolumeClaim: {claimName: daten}}]
EOF
# wait until the Pod runs (WaitForFirstConsumer: only now is the volume created)
kubectl -n speichertest wait pod/schreiber --for=condition=Ready --timeout=120s
# PVC bound, class local-path?
kubectl -n speichertest get pvc daten
# read the file in the volume
kubectl -n speichertest exec schreiber -- cat /daten/test
# remove the test – the provisioner deletes the volume too (reclaim Delete)
kubectl delete namespace speichertestExpected (shortened):
namespace/speichertest created
persistentvolumeclaim/daten created
pod/schreiber created
pod/schreiber condition met
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS ...
daten Bound pvc-dcd5742d-… 1Gi RWO local-path ...
gespeichert
namespace "speichertest" deleted
The names speichertest, daten and
schreiber are German for “storage test”, “data” and
“writer”; the output shows them exactly like that.
Checkpoint
# on cp1
kubectl get nodes -o wideExpected: three nodes Ready,
v1.37.2, containerd://2.4.2.
# on cp1
kubectl get pods -A --field-selector=status.phase!=RunningExpected: No resources found
# on cp1
cilium statusExpected: Cilium: OK,
Operator: OK, Envoy DaemonSet: OK,
Hubble Relay: OK, DaemonSet cilium with
Ready: 3/3.
# on cp1
helm list -AExpected: exactly one release cilium in
kube-system, chart cilium-1.20.5,
deployed.
# on cp1
kubectl -n kube-system get configmap cilium-config \
-o jsonpath='{.data.bpf-lb-sock} {.data.bpf-lb-sock-hostns-only}{"\n"}'Expected: false true
# on cp1
kubectl get gatewayclass ciliumExpected: ACCEPTED is
True.
# on cp1
kubectl top nodesExpected: CPU and memory values for
cp1, worker1 and worker2.
# on cp1
kubectl get storageclassExpected: local-path (default).
# on cp1
ssh 172.16.0.228 hostnameExpected: worker1 – without being asked
for a password or host key.
The training ground is ready. Continue with Day 0.
Enterprise Note
- Production clusters usually come from a distribution or a managed offering; building one by hand teaches you what happens under the hood there.
- In production,
k8sServiceHostpoints to a load balancer or a VIP in front of several API servers, never to a single node IP. - Cilium values belong in Git, versioned, instead of a long
--setline. - Hubble Relay with TLS, metrics-server without
--kubelet-insecure-tls, storage with replication instead of directories on a single node.