diff --git a/docs/09-bootstrapping-kubernetes-workers.md b/docs/09-bootstrapping-kubernetes-workers.md index ff9751a..5253ceb 100644 --- a/docs/09-bootstrapping-kubernetes-workers.md +++ b/docs/09-bootstrapping-kubernetes-workers.md @@ -16,11 +16,8 @@ for HOST in node01 node02; do 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}:~/ + scp 10-bridge.conf configs/kubelet-config.yaml \ + vagrant@${HOST}:~/ done ``` @@ -35,7 +32,8 @@ for HOST in node01 node02; do units/containerd.service \ units/kubelet.service \ units/kube-proxy.service \ - root@${HOST}:~/ + downloads/cni-plugins/ \ + vagrant@${HOST}:~/ done ``` @@ -43,7 +41,7 @@ done for HOST in node01 node02; do scp -r \ downloads/cni-plugins/ \ - root@${HOST}:~/cni-plugins/ + vagrant@${HOST}:~/cni-plugins/ done ``` @@ -51,7 +49,7 @@ The commands in the next section must be run on each worker instance: `node01`, `node02`. Login to the worker instance using the `ssh` command. Example: ```bash -ssh root@node01 +ssh vagrant@node01 ``` ## Provisioning a Kubernetes Worker Node @@ -60,8 +58,8 @@ Install the OS dependencies: ```bash { - apt-get update - apt-get -y install socat conntrack ipset kmod + sudo apt-get update + sudo apt-get -y install socat conntrack ipset kmod } ``` @@ -92,7 +90,7 @@ swapoff -a Create the installation directories: ```bash -mkdir -p \ +sudo mkdir -p \ /etc/cni/net.d \ /opt/cni/bin \ /var/lib/kubelet \ @@ -105,10 +103,10 @@ Install the worker binaries: ```bash { - mv crictl kube-proxy kubelet /usr/local/bin/ - mv runc /usr/local/sbin/ - mv containerd ctr containerd-shim-runc-v2 containerd-stress /bin/ - mv cni-plugins/* /opt/cni/bin/ + sudo mv crictl kube-proxy kubelet kubectl /usr/local/bin/ + sudo mv runc /usr/local/sbin/ + sudo mv containerd ctr containerd-shim-runc-v2 containerd-stress /bin/ + sudo mv cni-plugins/* /opt/cni/bin/ } ``` @@ -117,7 +115,7 @@ Install the worker binaries: Create the `bridge` network configuration file: ```bash -mv 10-bridge.conf 99-loopback.conf /etc/cni/net.d/ +sudo mv 10-bridge.conf 99-loopback.conf /etc/cni/net.d/ ``` To ensure network traffic crossing the CNI `bridge` network is processed by @@ -125,18 +123,16 @@ To ensure network traffic crossing the CNI `bridge` network is processed by ```bash { - modprobe br-netfilter - echo "br-netfilter" >> /etc/modules-load.d/modules.conf + sudo modprobe br-netfilter + echo "br-netfilter" | sudo tee -a /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 + echo "net.bridge.bridge-nf-call-iptables = 1" | sudo tee -a /etc/sysctl.d/kubernetes.conf + echo "net.bridge.bridge-nf-call-ip6tables = 1" | sudo tee -a /etc/sysctl.d/kubernetes.conf + sudo sysctl -p /etc/sysctl.d/kubernetes.conf } ``` @@ -146,9 +142,9 @@ Install the `containerd` configuration files: ```bash { - mkdir -p /etc/containerd/ - mv containerd-config.toml /etc/containerd/config.toml - mv containerd.service /etc/systemd/system/ + sudo mkdir -p /etc/containerd/ + sudo mv containerd-config.toml /etc/containerd/config.toml + sudo mv containerd.service /etc/systemd/system/ } ``` @@ -158,8 +154,8 @@ Create the `kubelet-config.yaml` configuration file: ```bash { - mv kubelet-config.yaml /var/lib/kubelet/ - mv kubelet.service /etc/systemd/system/ + sudo mv kubelet-config.yaml /var/lib/kubelet/ + sudo mv kubelet.service /etc/systemd/system/ } ``` @@ -167,8 +163,8 @@ Create the `kubelet-config.yaml` configuration file: ```bash { - mv kube-proxy-config.yaml /var/lib/kube-proxy/ - mv kube-proxy.service /etc/systemd/system/ + sudo mv kube-proxy-config.yaml /var/lib/kube-proxy/ + sudo mv kube-proxy.service /etc/systemd/system/ } ``` @@ -176,23 +172,38 @@ Create the `kubelet-config.yaml` configuration file: ```bash { - systemctl daemon-reload - systemctl enable containerd kubelet kube-proxy - systemctl start containerd kubelet kube-proxy + sudo systemctl daemon-reload + sudo systemctl enable containerd kubelet kube-proxy + sudo systemctl start containerd kubelet kube-proxy } ``` Check if the kubelet service is running: ```bash -systemctl is-active kubelet +sudo systemctl status kubelet ``` ```text -active +● kubelet.service - Kubernetes Kubelet + Loaded: loaded (/etc/systemd/system/kubelet.service; enabled; vendor preset: enabled) + Active: active (running) since Tue 2025-06-03 15:36:24 UTC; 28s ago + Docs: https://github.com/kubernetes/kubernetes + Main PID: 5645 (kubelet) + Tasks: 10 (limit: 1102) + Memory: 27.8M + CPU: 501ms + CGroup: /system.slice/kubelet.service + └─5645 /usr/local/bin/kubelet --config=/var/lib/kubelet/kubelet-config.yaml --kubeconfig=/var/lib/kubelet/kubeconfig --v=2 + +Jun 03 15:36:24 node02 kubelet[5645]: I0603 15:36:24.878735 5645 kubelet_node_status.go:687] "Recording event message for node" node="node02" event="NodeHasNoDiskPressure" +Jun 03 15:36:24 node02 kubelet[5645]: I0603 15:36:24.878809 5645 kubelet_node_status.go:687] "Recording event message for node" node="node02" event="NodeHasSufficientPID" +Jun 03 15:36:24 node02 kubelet[5645]: I0603 15:36:24.878879 5645 kubelet_node_status.go:75] "Attempting to register node" node="node02" +Jun 03 15:36:24 node02 kubelet[5645]: I0603 15:36:24.886841 5645 kubelet_node_status.go:78] "Successfully registered node" node="node02" ``` -Be sure to complete the steps in this section on each worker node, `node01` and `node02`, before moving on to the next section. +Be sure to complete the steps in this section on each worker node, `node01` +and `node02`, before moving on to the next section. ## Verification @@ -201,15 +212,15 @@ Run the following commands from the `jumpbox` machine. List the registered Kubernetes nodes: ```bash -ssh root@controlplane \ +ssh vagrant@controlplane \ "kubectl get nodes \ --kubeconfig admin.kubeconfig" ``` ``` -NAME STATUS ROLES AGE VERSION -node01 Ready 1m v1.33.1 -node02 Ready 10s v1.33.1 +NAME STATUS ROLES AGE VERSION +node01 Ready 2m5s v1.33.1 +node02 Ready 2m12s v1.33.1 ``` Next: [Configuring kubectl for Remote Access](10-configuring-kubectl.md) diff --git a/docs/10-configuring-kubectl.md b/docs/10-configuring-kubectl.md index 365bf7b..3b3707e 100644 --- a/docs/10-configuring-kubectl.md +++ b/docs/10-configuring-kubectl.md @@ -1,6 +1,7 @@ # Configuring kubectl for Remote Access -In this lab you will generate a kubeconfig file for the `kubectl` command line utility based on the `admin` user credentials. +In this lab you will generate a kubeconfig file for the `kubectl` command line +utility based on the `admin` user credentials. > Run the commands in this lab from the `jumpbox` machine. @@ -8,7 +9,8 @@ In this lab you will generate a kubeconfig file for the `kubectl` command line u Each kubeconfig requires a Kubernetes API Server to connect to. -You should be able to ping `controlplane.kubernetes.local` based on the `/etc/hosts` DNS entry from a previous lab. +You should be able to ping `controlplane.kubernetes.local` based on the +`/etc/hosts` DNS entry from a previous lab. ```bash curl --cacert ca.crt \ @@ -49,7 +51,9 @@ Generate a kubeconfig file suitable for authenticating as the `admin` user: kubectl config use-context kubernetes-the-hard-way } ``` -The results of running the command above should create a kubeconfig file in the default location `~/.kube/config` used by the `kubectl` commandline tool. This also means you can run the `kubectl` command without specifying a config. +The results of running the command above should create a kubeconfig file in +the default location `~/.kube/config` used by the `kubectl` commandline tool. +This also means you can run the `kubectl` command without specifying a config. ## Verification @@ -62,7 +66,7 @@ kubectl version ```text Client Version: v1.33.1 -Kustomize Version: v5.5.0 +Kustomize Version: v5.6.0 Server Version: v1.33.1 ``` @@ -73,9 +77,9 @@ kubectl get nodes ``` ``` -NAME STATUS ROLES AGE VERSION -node01 Ready 10m v1.33.1 -node02 Ready 10m v1.33.1 +NAME STATUS ROLES AGE VERSION +node01 Ready 15m v1.33.1 +node02 Ready 15m v1.33.1 ``` Next: [Provisioning Pod Network Routes](11-pod-network-routes.md) diff --git a/docs/11-pod-network-routes.md b/docs/11-pod-network-routes.md index 5091cf7..24afa5d 100644 --- a/docs/11-pod-network-routes.md +++ b/docs/11-pod-network-routes.md @@ -26,28 +26,28 @@ Print the internal IP address and Pod CIDR range for each worker instance: ``` ```bash -ssh root@controlplane <