Install And Configure Kubernetes

Lab Setup-:

Node7 – 192.168.11.9  -Kubernetes Master Node

Node8 – 192.168.11.10 – Kubernetes Worker Node

Step-1 – Make  an entry of each hosts in /etc/hosts file.

Step-2 – Disable swap on all nodes and make it permanent by comment out in /etc/fstab file.

               # swapoff –a

Step-3–  Enable Kubernetes repository on Master and all workers node.

#  vi   /etc/yum.repos.d/kubernetes.repo and add below entry in the file.

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0

Step-4–  Install docker kubeadm packages on Master and all workers node.

#    yum  install docker kubeadm

Step-5 – Start and enable Docker and Kublet services on Master and all worker nodes.

# systemctl start docker && systemctl enable docker
# systemctl start kubelet && systemctl enable kubelet

Step-6 – Allow all network ports in firewall on Master  and all worker nodes.

# firewall-cmd –permanent –add-port=6443/tcp   (kubernetes services endpoints)
# firewall-cmd –permanent –add-port=10250/tcp  (kebelets)
# firewall-cmd –reload

And also set “1” to bridge firewall rules.

#  echo ‘1’ > /proc/sys/net/bridge/bridge-nf-call-iptables

If you get  error “No such or directory” then load the module “br_netfilter” and try the command again.

# modprobe  br_netfilter

Step-7– Initializing and setting up kubernetes cluster on master node.

kubeadm init –apiserver-advertise-address 192.168.2.1 –pod-network-cidr=172.16.0.0/16

Step-8– Copy /etc/kubernetes/admin.conf and change ownership only on Master node.

# mkdir -p $HOME/.kube
# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# sudo chown $(id -u):$(id -g) $HOME/.kube/config

Step-9–  Install network add-on to enable the communication between the pods only on master node.

              Note- In this case we have used flannel network provider.

  # kubectl apply -f  https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Step-10–   Verify the master node is is reday state.

# kubectl get nodes

Step-11– Join worker node with master node.

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *