Kubernetes Install - travisriddle/docs GitHub Wiki
Summary Install a Kubernetes Cluster on my local infrastructure for testing and learning.
Requirements
Ubuntu 22.04
Reference
Steps
Install and configure containerd as a k8s container runtime
Modify /etc/sysctl.conf to enable packet forwarding for IPV4
sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
Create k8s.conf file to load modules
- Create /etc/modules-load.d/k8s.conf to load the following two modules
cat <<EOF | sudo tee /etc/modules-load.d/k8s.confoverlaybr_netfilterEOF - Configure required modules
sudo modprobe overlaysudo modprobe br_netfilter - Configure sysctl to persist after reboot
cat <<EOF | sudo tee /etc/sysctl.d/k8s.confnet.bridge.bridge-nf-call-iptables = 1net.bridge.bridge-nf-call-ip6tables = 1net.ipv4.ip_forward = 1EOF - You can apply these settings without rebooting
sudo sysctl --system
Install containerd
-
Use apt to install
sudo apt install containerd -
Create direcotry
sudo mkdir /etc/containerd -
Create initial config file
containerd config default | sudo tee /etc/containerd/config.toml -
Update the parameter SystemdCgroup = true
sudo sed -i 's/ SystemdCgroup = false/ SystemdCgroup = true/' /etc/containerd/config.toml -
Or you can manually change the parameter by editing the file
sudo vi /etc/containerd/config.toml
Turn off swap
- Immediately turn off swap
sudo swapoff -a - Modify fstab and comment out swap to prevent it from mounting on reboot
Example:
Restart conatinerd
- Now that containerd is configured, we need to restart it to apply the new configuration
sudo systemctl restart containerd
Install Kubernetes Tools
sudo apt-get install -y apt-transport-https ca-certificates curl gpg
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.31/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
sudo systemctl enable --now kubelet
sudo kubeadm init