banner



How To Install And Configure Kubernetes On Centos 7

In this blog post , We have explained how to install and configure kubernetes on Centos

We will see how to setup kubernetes primary slave architecture from the scratch.

What is Kubernetes?

Kubernetes is an open-source tool for automating deployment , scaling and managing of containerized applications.

We can build an docker images and we can run containers out of it using Docker engine.

And kubernetes will help in managing those containers by loadbalancing and scaling between the containers.

Prerequisites

For setting up Master Slave kubernetes compages , We need,

  • Minimum 2 or more Centos operating systems.
  • Yous should accept admission to the servers with sudo or root privileges

In this tutorial , We will learn to setup one Master node and 1 Worker node setup.

The first step is to install docker on all the servers of the kubernetes nodes.

Installing Docker

Kubernetes requires Docker to be installed on all the Centos servers.

If you have already installed docker on all the arrangement , You can ignore this this , If non , Check this article  , To install Docker on Centos servers.

Once the docker is installed , Make sure the docker service is Upward and running on master and worker nodes using the below command.

          sudo systemctl status docker        
install and configure kubernetes

Lets go ahead and install kubernetes on the nodes.

Installing Kubernetes

In this pace We are going to install tools such every bit kubeadm , kubelet and kubectl.

The post-obit steps should be executed on all the servers.

If curl package is not installed , Install information technology using ,

          yum install curl -y        

So we need to add the kubernetes repository on all the servers.

create a file and then add together the beneath contents as shown below.

          six /etc/yum.repos.d/kubernetes.repo        
          [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 enabled=ane gpgcheck=1 repo_gpgcheck=one gpgkey=https://packages.cloud.google.com/yum/doc/yum-cardinal.gpg https://packages.cloud.google.com/yum/md/rpm-package-key.gpg        

Installing Kubernetes Tools

Here nosotros are going to install tools such as kubeadm , kubelet and kubectl.

kubeadm is a tool which helps you to install and prepare a Kubernetes cluster.

kubelet is thenode agent that runs on each node which helps to first 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        
kubernetes

Kickoff and Enable the Kubectl,

          systemctl start kubelet        
          systemctl enable kubelet        
          systemctl status kubelet        

Lets cheque the version of kubernetes tools installed on the servers and also make certain to maintain same versions on all the servers.

          kubelet --version        
          kubeadm version        
          kubectl version        
kubernetes

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 bandy using the control,

          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 higher up command y'all may become the below mistake.

install and configure kubernetes

Make sure the servers has minimum of ii vCPU to successfully initialize the kubernetes.

If the above control is successful , At the end , It will displaykubeadm join bulletin at the end.

Make a note of the unabridged line (command).Using will we will join the worker nodes with the master node.

To beginning using the cluster , We need to setup folders for the kubernetes cluster.

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

Then we demand to deploy pod network to the cluster.

Pod network is a way to make communications betwixt the nodes in the cluster.

Lets deploy aFlannel virtual network into the cluster using the below command.

          sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml        
install and configure kubernetes

The Flannel pod network volition exist delpoyed into the kube-system namespace.

To listing all the pods running across the namespaces , Run the beneath command.

          kubectl get po --all-namespaces        
kubernetes

Some of the useful commands equally follows.

To listing all the namespaces in the cluster

          kubectl get ns        

To listing the nodes in the cluster

          kubectl get nodes        

You tin come across only the master node within the cluster.As we havn't joined the worker nodes within the cluster still.

install and configure kubernetes

Lets go alee and join the worker nodes to the cluster.

Joining Worker Nodes to the Cluster

To join worker nodes with the inside the cluster , We need thekubeadm bring together command , Which we got while initializing the cluster in the chief node.

Now Login to worker nodes and run the kubeadm join command.

          kubeadm bring together 172.31.2.73:6443 --token 2txg2t.mb2fi46jhd837wev --discovery-token-ca-cert-hash sha256:ce920cea8732eeab34dac71411e75acb56782hss7250281687934ac9644977e26        

Don't forget to replace–token and–discovery-token-ca-cert-hash with your value.

Note: Brand certain the worker nodes are able to reach port 6443 on the master node. Check the firewall.

Once the control is successfully executed , You should get the beneath response.

install and configure kubernetes

From the higher up epitome , You tin can see that the worker node is successfully joined with the kubernetes cluster.

Now Login to Main node and run the below control,

          kubectl get no        

You can see that the worker node is successfully joined to the cluster.

install and configure kubernetes

Decision

Nosotros have successfully installed and configured kubernetes cluster on the Centos Operating system.

Thanks for reading , Please practice check out my other blogs.

Source: https://fitdevops.in/how-to-install-and-configure-kubernetes-on-centos-7/

Posted by: normanlowelies.blogspot.com

0 Response to "How To Install And Configure Kubernetes On Centos 7"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel