Here we are going to install tools such as kubeadm , kubelet and kubectl.
kubeadm is a tool which helps you to install and set up a Kubernetes cluster.
kubelet is the node agent that runs on each node which helps to start containers and registere the node with the api server.
kubectl is a command line tool using which you can control kubernetes cluster.
Install the above packages using the below command.
yum install kubeadm kubectl kubelet -y
Start and Enable the Kubectl,
systemctl start kubelet
systemctl enable kubelet
systemctl status kubelet
Lets check the version of kubernetes tools installed on the servers and also make sure to maintain same versions on all the servers.
kubelet --version
kubeadm version
kubectl version
Before initializing kubernetes on master nodes we need to setup proper hostname on all the servers and disable swap on all the servers using the below commands.
hostnamectl set-hostname master-node
hostnamectl set-hostname slave-node
If you have multiple slave nodes , Setup hostnames accordingly.
Then disable swap using the command,
sudo swapoff -a
Initializing Kubernetes on Master Node
Login to master node and enter the below command to initialize kubernetes.
kubeadm init --pod-network-cidr=172.31.0.0/20
And while running the above command you may get the below error.
Make sure the servers has minimum of 2 vCPU to successfully initialize the kubernetes.
If the above command is successful , At the end , It will display kubeadm join message at the end.
Make a note of the entire line (command).Using will we will join the worker nodes with the master node.
To start using the cluster , We need to setup folders for the kubernetes cluster.