SETUP
Install packages for master
Disable SWAP:
sudo swapoff -a
Install docker:
sudo apt install -y docker.io
Debian, Ubuntu, and operating systems using apt/apt-get
Replace the apt repository definition so that apt points to the new repository instead of the Google-hosted repository. Make sure to replace the Kubernetes minor version in the command below with the minor version that you're currently using:
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
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:
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
Update: In releases older than Debian 12 and Ubuntu 22.04, the folder /etc/apt/keyrings does not exist by default, and it should be created before the curl command.
Update the apt package index:
sudo apt-get update
Install Kubernetes components:
sudo apt-get install -y kubelet kubeadm kubectl
Install packages for worker node/s
Disable SWAP:
sudo swapoff -a
https://kubernetes.io/blog/2023/08/15/pkgs-k8s-io-introduction/
Install docker:
sudo apt install -y docker.io
Debian, Ubuntu, and operating systems using apt/apt-get
Replace the apt repository definition so that apt points to the new repository instead of the Google-hosted repository. Make sure to replace the Kubernetes minor version in the command below with the minor version that you're currently using:
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
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:
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
Update: In releases older than Debian 12 and Ubuntu 22.04, the folder /etc/apt/keyrings does not exist by default, and it should be created before the curl command.
Update the apt package index:
sudo apt-get update
Install Kubernetes components:
apt-get install -y kubelet kubeadm kubectl
Initialise Kubernetes Control Plane (Master)
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
--pod-network-cidr=192.168.0.0/16: This specifies the CIDR range for Pod networking. This value might differ depending on the CNI (Container Network Interface) plugin you choose later.
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
Configure pod network
Kubernetes requires a network add-on to enable communication between Pods. There are several options available, such as Calico, Flannel, and Weave. For this example, let’s use Calico. From the Control Plane:
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
Note: Ensure the CIDR specified in kubeadm init matches the network add-on requirements.
Join the worker nodes to the cluster:
sudo kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash <hash>
Replace <master-ip>, <master-port>, <token>, and <hash> with the values provided by the output of kubeadm init. In this example, my output was:
kubeadm join 192.168.1.114:6443 --token tw8h7m.1yjwutss70lfyn89 --discovery-token-ca-cert-hash sha256:d08527b8e9c3ca103ffd911d7b0fa142aec3e14914e2d78f974aae74f0641fc9
Configure container network
There are various network plugins available for kuberenetes;
Calico
Pull configuration on control-plane:
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
Check cluster state:
kubectl get nodes
Example;
root@k8s-ma:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-ma Ready control-plane 13m v1.28.14
k8s-worker1 NotReady <none> 12m v1.28.14
k8s-worker2 Ready <none> 12m v1.28.14
No Comments