How to Install Kubernetes on Debian
- 5 minsBefore Installation of K8s?
- We will install K8s to Debian nodes. The lab will include 1 master and 1 worker node, We will use Debian 10 Buster. If you want to use different distros probably It works for nmost of Debian or Ubuntu Versions.
- Note: The recommendation is using at least 2 CPU for master node.
K8s Installation
- You may need to edit your 2 machines hostnames. master-node and worker-node (slave)
- You need to follow up the steps for both master and slave nodes.
Install Containerd Run time on All Nodes
- Containerd is the industry standard container run time and supported by Kubernetes. So, install containerd on all master and worker nodes.
- Before installing containerd, set the following kernel parameters on all the nodes.
- To make above changes into the effect, run
We need to install containerd and settingup contianerd for k8s.
- Next, configure containerd so that it works with Kubernetes, run beneath command on all the nodes.
- Set cgroupdriver to systemd on all the nodes,
- Edit the file ‘/etc/containerd/config.toml’ and look for the section ‘[plugins.”io.containerd.grpc.v1.cri”.containerd.runtimes.runc.options]’ and change ‘SystemdCgroup = false’ to ‘SystemdCgroup = true‘
-
Save and exit
-
Restart and enable containerd service on all the nodes,
Install curl for both nodes.
Add the Kubernetes signing key on both the nodes.
- I f you get any error regarding to gnupg, gnupg2 and gnupg1 probably You need to install one of it ex. apt-get install -y gnupg2
Add Kubernetes Repository on both the nodes.
- We will be using Xenial Kubernetes Repository
- Update apt afte radding new repo
Install Kubeadm and some k8s tools on both the nodes.
- This is the final step for installation. Installing kubeadm on both the nodes
- We successfully installed K8s and We can deploy K8s cluster now
Install Kubernetes Cluster with Kubeadm
- Now, we are all set to initialize Kubernetes cluster, run following command only from master node,
We need to disable SWAP memory (SWAP RAM), on both the nodes as Kubernetes does not perform properly on systems that is using swap memory.
- You may need to comment out fstab entry for SWAP (For permanently disable SWAP)
Before Initialize K8s I would like to change hostname of VMs for better understanding
Initialize K8s in Master-node i.e master-node
- Run the following command only in master-node
-
Above output confirms that control plane has been initialized successfully. In the output, we have commands for regular user for interacting with the cluster and also the command to join any worker node to this cluster.
-
To start interacting with cluster, run following commands on master node,
- And It gives you another command for join any worker to the cluster.
- Run following kubectl command to get nodes and cluster information,
-
On your worker nodes, join them to the cluster by running the command that was displayed when you initialized the master node. It will look something like this ‘Kubeadm join’
-
Note: Copy worker node join command from output and run it in worker(slave) node.
Check the nodes status by running following command from master node,
- To make nodes status ready, we must install POD network addons like Calico or flannel.
Setup Pod Network Using Calico
- On the master node, run beneath command to install calico,
- and verify the status of Calico pods, run
- After waiting couple minutes all pods will be ready and If you check nodes , It will show you all nodes are ready state.
You are ready for deploy applications. Enjoy with your Kubernetes Cluster
Guneycan Sanli.