Skip to content

Latest commit

 

History

History
146 lines (102 loc) · 3.21 KB

lab-01.md

File metadata and controls

146 lines (102 loc) · 3.21 KB

Lab 01 - k8s cluster setup

Documentation

Step 1 - Installing containerd

Task 1.1 - Prerequisites

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

Task 1.2 - Install containerd package

sudo apt-get update && sudo apt-get install -y containerd

Task 1.3 - Configure containerd

sudo mkdir -p /etc/containerd
sudo containerd config default | sudo tee /etc/containerd/config.toml
sudo systemctl restart containerd
sudo systemctl status containerd

Step 2 - Installing Kubernetes packages

Task 2.1 - Prerequisites

sudo swapoff -a

# IMPORTANT: in real life also check /etc/fstab for configured swap (comment out or remove line(s) entirely)
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl gpg

Task 2.2 - Add repo

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list

Task 2.3 - Install packages

sudo apt-get update && sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

Step 3 - Installing Kubernetes cluster (control plane)

Task 3.1 - Run kubeadm init command

NOTE: only on control plane node

sudo kubeadm init --pod-network-cidr 192.168.0.0/16 --kubernetes-version=1.29.0

Task 3.2 - Configure kubectl

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Task 3.3 - Check kubectl configuration

kubectl get nodes

Step 4 - Install calico network plugin

Task 4.1 - Apply calico manifest file

kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/tigera-operator.yaml
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/custom-resources.yaml

Task 4.2 - Check calico installation

kubectl get pods -n calico-system
kubectl get nodes

Step 5 - Add additional worker nodes

Task 5.1 - Get join command

kubeadm token create --print-join-command

Task 5.2. - Join additional worker node

sudo kubeadm join 10.0.1.101:6443 --token kjml1s.hspasotb2a0ny8s3 --discovery-token-ca-cert-hash sha256:c5a18b0c6dc74ba83a5f843f07e443fe7e8c3498f940ceb2610c4932f5cc53fb

# IMPORTANT: use output from the command in 5.1 here

Task 5.2 - Validate additional worker node

kubectl get nodes