Script "/etc/keepalived/check_apiserver.sh"
Now paste the following contents to /etc/keepalived/nf file ~]$ sudo vi /etc/keepalived/nf ~]$ sudo cp /etc/keepalived/nf /etc/keepalived/nf-org Take the backup of nf file and then truncate the file. Set the executable permissions $ sudo chmod +x /etc/keepalived/check_apiserver.sh
Install keepalived and haproxy on each master node using the following yum command, $ sudo yum install haproxy keepalived -yĬonfigure Keepalived on k8s-master-1 first, create check_apiserver.sh script will the following content, ~]$ sudo vi /etc/keepalived/check_apiserver.shĬurl -silent -max-time 2 -insecure -o /dev/null || errorExit "Error GET if ip addr | grep -q $ thenĬurl -silent -max-time 2 -insecure -o /dev/null || errorExit "Error GET fi Step 2) Install and Configure Keepalive and HAProxy on all master / control plane nodes All the kube-apiserver request will come to this IP and then the request will be distributed among backend actual kube-apiservers. This IP will be used as kube-apiserver load balancer ip. I have used one additional entry “ 192.168.1.45 vip-k8s-master” in host file because I will be using this IP and hostname while configuring the haproxy and keepalived on all master nodes. Once hostname is set on all master and worker nodes then add the following entries in /etc/hosts file on all the nodes. Similarly, run above command on remaining nodes and set their respective hostname. Run hostnamectlcommand to set hostname on each node, example is shown for k8s-master-1 node, $ hostnamectl set-hostname "k8s-master-1" Let’s jump into the installation and configuration steps Step 1) Set Hostname and add entries in /etc/hosts file Root credentials or sudo privileges user on all nodes.Network Connectivity among master and worker nodes.Install Kubeadm, kubelet and kubectl on all master and worker Nodes.Minimum requirements for setting up Highly K8s cluster Note: etcd cluster can also be formed outside of master nodes but for that we need additional hardware, so I am installing etcd inside my master nodes.