Install Kubernetes on centos

50 %
50 %
Information about Install Kubernetes on centos

Published on September 12, 2019

Author: linuxdady


slide 1: LinuxDady.Com How to install Kubernetes in Centos/Redhat 7 For more information visit slide 2: How to install Kubernetes on Centos step by step BY DEEPAK KUMAR · PUBLISHED SEPTEMBER 11 2019 · UPDATED SEPTEMBER 12 2019 Every DevOps engineer should be aware about how to install Kubernetes on Centos or Redhat. There are mainly two way to install Kubernetes on Centos. Let’s discuss one by one our first method is by rpm package and second one is by docker image. Kubernetes community is providing its docker images. Simply pull those docker images form docker hub and launch the Kubernetes containers. Install Kubernetes on Centos Here we will install Kubernetes on Centos by docker image instead of rpm package. The advantage of doing Kubernetes installation by docker image is we can easily recover our container. If we are facing any issue instead of rpm package. Prerequisite for Kubernetes ▪ OS –:: – Centos 7.6 plus ▪ Two machine –:: – Kubernetes master and Kubernetes Node ▪ Docker should be installed on both Kubernetes master and Kubernetes Node Change your host name and disable selinux policy if required. In my case I have set host name kube-master. 1 2 3 4 5 cat /etc/redhat-release hostnamectl set-hostname kube-master bash setenforce 0 sed -i --follow-symlinks s/SELINUXenforcing/SELINUXdisabled/g /etc/sysconfig/selinux Run the command below to enable the br_netfilter kernel module. 1 2 modprobe br_netfilter echo 1 /proc/sys/net/bridge/bridge-nf-call-iptables Click Read: – What is kubernetes and its terminology for beginner 1 swapoff -a slide 3: Add below port number in you firewall permanently. Because kubernetes services will use these port number. If firewall not required we can disabled its service. Then no need to add port number. 1 2 3 4 5 6 7 firewall-cmd --permanent --add-port6443/tcp firewall-cmd --permanent --add-port2379-2380/tcp firewall-cmd --permanent --add-port10250/tcp firewall-cmd --permanent --add-port10251/tcp firewall-cmd --permanent --add-port10252/tcp firewall-cmd --permanent --add-port10255/tcp firewall-cmd --reload L e t ’ s install kubernetes on centos kubeadm –:– This is installation utility of Kubernetes. It will automatically pull the docker image of kubernetes services like etcd scheduler controller kube api from docker hub and it will launch the containers as required no need to do any manual effort. So kubeadm package should be installed on kubernetes master server. But it is not available in default repository of Centos. So we have to use third party repository for kubeadm. 1 vim /etc/yum.repos.d/kubernetes.repo 1 2 3 4 5 kubernetes nameKubernetes baseurl enabled1 gpgcheck0 Our repository has been successfully added. Now let’s install required package for kubernetes. 1 yum install kubectl kubeadm docker wget telnet -y Now start and enable services of docker and kubelet. 1 2 3 4 systemctl restart docker systemctl enable docker systemctl restart kubelet systemctl enable kubelet Run the script that will automatic launch the Kubernetes services container. Below command will install kubernetes on centos. But first it will initialize our machine hardware. After that it will check we have enough resource or not. 1 kubeadm init Suppose if we don’t have enough resource then use below command instead of above. That will skip pre hardware check test. 1 kubeadm init --ignore-preflight-errorsall slide 4: Note down kubeadm join command that is shown in above fig. It will use when we will add cluster into kubernetes master. Now set the admin credential path for kubernetes user. 1 2 3 4 mkdir -p HOME/.kube cp -ivr /etc/kubernetes/admin.conf HOME/.kube/config chown id -u:id -g HOME/.kube/config docker ps Installation of kubernetes on centos has been competed. Now check status of docker and kubelet service. These service should be in running state. 1 systemctl status kubelet docker Now check Our installation of Kubernetes on centos has been working properly or not. 1 kubectl get node slide 5: 2 3 kubectl get namespace kubectl get pods --all-namespaces Install kubernetes on centos towards worker node Our Kubernetes installation task has been done towards kubernetes master side. Now move to kubernetes client node and add repository for kubernetes package. 1 vim /etc/yum.repos.d/kubernetes.repo 1 2 3 4 5 kubernetes nameKubernetes baseurl enabled1 gpgcheck0 1 yum install kubeadm docker -y No need to run kubeadm init command because this is client machine. That command will run only server side. 1 2 3 4 systemctl restart docker systemctl enable docker systemctl restart kubelet systemctl enable kubelet After starting service on client node add this node to kubernetes cluster from below command. Change token and IP address of your machine accordingly or simply copy that command we have noted in earlier above steps. 1 kubeadm join --token zjsos5.1io42shjxjca4lwq --discovery-token-unsafe-skip-ca-verification slide 6: I have skipped the ca token verification in your case depend on your choice. Now go to master and check client node has been added or not from below command. 1 kubectl get node From above image it is clear that our kubernetes node or worker node has been added successfully. But still this is showing in NotReady state. Because still our networking configuration is pending. So we have to create virtual switch for networking. At this time in market we have different type of ISDN Internal software define network switch like ▪ OVS ▪ Flannel ▪ Weave But kubernetes recommends weave networking for pod communication to each other into the cluster. So let’s create weave ISDN from below command. This command will run on kubernetes master side. 1 kubectl apply -f " version | base64 | tr -d \n" slide 7: Our weave network has been setup properly. Now check state of cluster node. 1 kubectl get node Now these are in Ready state means we have properly integrated weave network with Kubernetes. So here we have install kubernetes on centos and then setup weave network for kubernetes pod. In next tutorial we learn about how to deploy service or you can say new pod in Kubernetes. Conclusion I think now you can easily install Kubernetes on centos or any other Linux based flavor. Because Kubernetes installation process is almost same on all Linux based OS. We have installed Kubernetes on centos because if you will select Redhat then you have to take subscription. For learn purpose this is not OK. But for running or production infra I will recommend Redhat. Interview question related to Kubernetes ▪ What will be backup planning for Kubernetes ▪ How much space we should provide to Kubernetes service like etcd controller scheduler kube-api ▪ Interviewer can ask about port number of Kubernetes. ▪ Is there any need to plan high availability for Kubernetes master node slide 8: ▪ How much validity of Kubernetes token ▪ Suppose out of four running container kube api goes down what will impact on Kubernetes master node ▪ Which one ISDN technology is recommended for networking in Kubernetes ▪ If our Kubernetes master node goes down what will be impact on client node

Add a comment

Related presentations