# Bootstrapping the Kubernetes Worker Nodes In this lab you will bootstrap two Kubernetes worker nodes. The following components will be installed: [runc](https://github.com/opencontainers/runc), [container networking plugins](https://github.com/containernetworking/cni), [containerd](https://github.com/containerd/containerd), [kubelet](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet), and [kube-proxy](https://kubernetes.io/docs/concepts/cluster-administration/proxies). ## Prerequisites The commands in this section must be run from the `jumpbox`. Copy the Kubernetes binaries and systemd unit files to each worker instance: ```bash for host in node-0 node-1; do SUBNET=$(grep $host machines.txt | cut -d " " -f 4) sed "s|SUBNET|$SUBNET|g" \ configs/10-bridge.conf > 10-bridge.conf sed "s|SUBNET|$SUBNET|g" \ configs/kubelet-config.yaml > kubelet-config.yaml scp 10-bridge.conf kubelet-config.yaml \ root@$host:~/ done ``` ```bash for host in node-0 node-1; do scp \ downloads/runc.arm64 \ downloads/crictl-v1.32.0-linux-arm64.tar.gz \ downloads/cni-plugins-linux-arm64-v1.6.2.tgz \ downloads/containerd-2.1.0-beta.0-linux-arm64.tar.gz \ downloads/kubectl \ downloads/kubelet \ downloads/kube-proxy \ configs/99-loopback.conf \ configs/containerd-config.toml \ configs/kube-proxy-config.yaml \ units/containerd.service \ units/kubelet.service \ units/kube-proxy.service \ root@$host:~/ done ``` The commands in the next section must be run on each worker instance: `node-0`, `node-1`. Login to the worker instance using the `ssh` command. Example: ```bash ssh root@node-0 ``` ## Provisioning a Kubernetes Worker Node Install the OS dependencies: ```bash { apt-get update apt-get -y install socat conntrack ipset kmod } ``` > The socat binary enables support for the `kubectl port-forward` command. Disable Swap Kubernetes has limited support for the use of swap memory, as it is difficult to provide guarantees and account for pod memory utilization when swap is involved. Verify if swap is disabled: ```bash swapon --show ``` If output is empty then swap is disabled. If swap is enabled run the following command to disable swap immediately: ```bash swapoff -a ``` > To ensure swap remains off after reboot consult your Linux distro documentation. Create the installation directories: ```bash mkdir -p \ /etc/cni/net.d \ /opt/cni/bin \ /var/lib/kubelet \ /var/lib/kube-proxy \ /var/lib/kubernetes \ /var/run/kubernetes ``` Install the worker binaries: ```bash { mkdir -p containerd tar -xvf crictl-v1.32.0-linux-arm64.tar.gz tar -xvf containerd-2.1.0-beta.0-linux-arm64.tar.gz -C containerd tar -xvf cni-plugins-linux-arm64-v1.6.2.tgz -C /opt/cni/bin/ mv runc.arm64 runc chmod +x crictl kubectl kube-proxy kubelet runc mv crictl kubectl kube-proxy kubelet runc /usr/local/bin/ mv containerd/bin/* /bin/ } ``` ### Configure CNI Networking Create the `bridge` network configuration file: ```bash mv 10-bridge.conf 99-loopback.conf /etc/cni/net.d/ ``` To ensure network traffic crossing the CNI `bridge` network is processed by `iptables`, load and configure the `br-netfilter` kernel module: ```bash { modprobe br-netfilter echo "br-netfilter" >> /etc/modules-load.d/modules.conf } ``` ```bash { echo "net.bridge.bridge-nf-call-iptables = 1" \ >> /etc/sysctl.d/kubernetes.conf echo "net.bridge.bridge-nf-call-ip6tables = 1" \ >> /etc/sysctl.d/kubernetes.conf sysctl -p /etc/sysctl.d/kubernetes.conf } ``` ### Configure containerd Install the `containerd` configuration files: ```bash { mkdir -p /etc/containerd/ mv containerd-config.toml /etc/containerd/config.toml mv containerd.service /etc/systemd/system/ } ``` ### Configure the Kubelet Create the `kubelet-config.yaml` configuration file: ```bash { mv kubelet-config.yaml /var/lib/kubelet/ mv kubelet.service /etc/systemd/system/ } ``` ### Configure the Kubernetes Proxy ```bash { mv kube-proxy-config.yaml /var/lib/kube-proxy/ mv kube-proxy.service /etc/systemd/system/ } ``` ### Start the Worker Services ```bash { systemctl daemon-reload systemctl enable containerd kubelet kube-proxy systemctl start containerd kubelet kube-proxy } ``` Check if the kubelet service is running: ```bash systemctl is-active kubelet ``` ```text active ``` Be sure to complete the steps in this section on each worker node, `node-0` and `node-1`, before moving on to the next section. ## Verification Run the following commands from the `jumpbox` machine. List the registered Kubernetes nodes: ```bash ssh root@server \ "kubectl get nodes \ --kubeconfig admin.kubeconfig" ``` ``` NAME STATUS ROLES AGE VERSION node-0 Ready 1m v1.32.3 node-1 Ready 10s v1.32.3 ``` Next: [Configuring kubectl for Remote Access](10-configuring-kubectl.md)