6.2 KiB
K8s Manual Install
Pre-requisites for each node
Remove any exiting docker components (Not required if host is new)
sudo apt remove docker docker-engine docker.io containerd runc
Install required packages
sudo apt install curl ca-certificates apt-transport-https containerd nfs-common gpg
Disable Swap
sudo swapoff -a
Comment out swap line in /etc/fstab
sudo vim /etc/fstab
Create containerd conf file
sudo vim /etc/modules-load.d/containerd.conf
Add the following:
overlay
br_netfilter
Insert the overlay and br_netfilter modules
sudo modprobe overlay && sudo modprobe br_netfilter
Create 99-kubernetes-cri.conf file
sudo vim /etc/sysctl.d/99-kubernetes-cri.conf
Add the following:
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
Apply changes without reboot
sudo sysctl --system
Create default containerd config
sudo mkdir /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
Make sure the following options are set in the specified locations in the file
version = 2
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
[plugins."io.containerd.grpc.v1.cri".containerd]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
Restart Containerd
sudo systemctl restart containerd
Install kubernetes repo and packages
Note: The legacy package repositories (apt.kubernetes.io and yum.kubernetes.io) have been deprecated and frozen starting from September 13, 2023. Using the new package repositories hosted at pkgs.k8s.io is strongly recommended and required in order to install Kubernetes versions released after September 13, 2023. The deprecated legacy repositories, and their contents, might be removed at any time in the future and without a further notice period. The new package repositories provide downloads for Kubernetes versions starting with v1.24.0. - Reference
These instructions are for Kubernetes 1.29.
Download the public signing key for the Kubernetes package repositories.
The same signing key is used for all repositories so you can disregard the version in the URL
# If the folder `/etc/apt/keyrings` does not exist, it should be created before the curl command.
# sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
Add the appropriate Kubernetes apt repository.
Please note that this repository has packages only for Kubernetes 1.29; for other Kubernetes minor versions, you need to change the Kubernetes minor version in the URL to match your desired minor version (you should also check that you are reading the documentation for the version of Kubernetes that you plan to install).
# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
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
Update the apt package index, install kubelet, kubeadm and kubectl, and pin their version:
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
Initialize the cluster
Perform the rest of the steps from the control-plane (master node) only!
Initialize the cluster with kubeadm
sudo kubeadm init --upload-certs --pod-network-cidr 10.244.0.0/16
You should get output similar to the following:
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.48.134:6443 --token vhcdvr.1c8gqc6s5qpiukt7 \
--discovery-token-ca-cert-hash sha256:697968c82f451ea0174d7abcc17a7c6e347f9c55963846659233624dd10cde57
Follow the directions in the output to copy and change ownership on the config file.
Deploy flannel
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
Join worker nodes
Use the command in the output to join worker nodes to the cluster.
As root on each worker node:
kubeadm join 192.168.48.134:6443 --token vhcdvr.1c8gqc6s5qpiukt7 --discovery-token-ca-cert-hash sha256:697968c82f451ea0174d7abcc17a7c6e347f9c55963846659233624dd10cde57
Verify cluster from the control-plane (Master Node)
kube@devitkubm1a:~$ kubectl get nodes
Sample output
NAME STATUS ROLES AGE VERSION
devitkub1a Ready <none> 34s v1.29.1
devitkub1b Ready <none> 15s v1.29.1
devitkubm1a Ready control-plane 10m v1.29.1