Install Kubernetes Cluster on CentOS8

Kubernetes Cluster Install on CentOS

In this tutorial, we will review the Kubernetes cluster install on CentOS8. This procedure will mirror our previous article about this subject.

Install a Kubernetes Cluster on Ubuntu 20.04

Also, this procedure will work for setting up a Kubernetes Cluster on CentOS7 or CentOS9.

Table of Contents

Introduction

Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF). Kubernetes is widely used in the industry and has become the de facto standard for container orchestration. In this essay, we will provide a detailed guide on how to install a Kubernetes cluster on CentOS machines.

What is Kubernetes?

Kubernetes is a container orchestration platform that automates the deployment, scaling, and management of containerized applications. It was designed to solve the challenges of deploying and managing containerized applications at scale. Kubernetes provides a declarative API for defining the desired state of the system, and a control plane that continuously monitors the system and makes adjustments to ensure that the desired state is achieved.

It has several key components that work together to provide a scalable, fault-tolerant platform for running containerized applications. The core components include:

  1. Master components: The master components are responsible for managing the state of the Kubernetes cluster. They include the API server, etcd, the scheduler, and the controller manager.

  2. Node components: The node components are responsible for running the containerized applications. They include the kubelet, the kube-proxy, and the container runtime.

  3. Add-on components: Add-on components are optional features that provide additional functionality to the Kubernetes cluster. Examples include the DNS add-on, which provides a DNS service for the cluster, and the dashboard add-on, which provides a web-based user interface for managing the cluster.

What is a Kubernetes Cluster?

A Kubernetes cluster is a group of machines that run the Kubernetes platform. A cluster consists of one or more master nodes and one or more worker nodes. The master nodes are responsible for managing the state of the cluster, while the worker nodes are responsible for running the containerized applications.

A Kubernetes cluster provides several benefits over running containers directly on a single machine. It provides a scalable and fault-tolerant platform for running containerized applications, and it enables the deployment of applications to multiple machines for better resource utilization. Additionally, Kubernetes provides a declarative API for defining the desired state of the system, which makes it easier to manage complex applications.

CentOS Version for Kubernetes

CentOS is a popular distribution of the Linux operating system and is widely used in the industry. When it comes to running a Kubernetes cluster on CentOS, the most suitable and stable version is CentOS 7(as of the date of this publication). This version of CentOS has long-term support (LTS) and is well tested and supported by the Kubernetes community. Additionally, CentOS 7 provides a stable and secure environment for running containerized applications. However, these procedures will work for setting up a Kubernetes Cluster on CentOS 8 or 9.

Kubernetes Cluster Install on CentOS: Installation (Step-by-Step)

To install Kubernetes on CentOS, we will use kubeadm, a tool for setting up a Kubernetes cluster. We will install Kubernetes on three CentOS machines: one master node and two worker nodes. Here are the steps for installing Kubernetes on CentOS:

Step 1: Install Docker

Kubernetes uses Docker as the container runtime. To install Docker on CentOS, run the following commands:

For CentOS 7:

				
					$ sudo yum install -y yum-utils 
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 
$ sudo yum install -y docker-ce 
$ sudo systemctl enable docker 
$ sudo systemctl start docke
				
			

For CentOS 8:

				
					$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo 
$ sudo dnf install docker-ce docker-ce-cli containerd.io -y 
$ sudo systemctl start docker 
$ sudo systemctl enable docker
				
			

For CentOS 9:

				
					$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo 
$ sudo dnf install docker-ce docker-ce-cli containerd.io -y 
$ sudo systemctl start docker 
$ sudo systemctl enable docker
				
			

Step 2: Disable SELinux

SELinux is a security feature in CentOS that can interfere with the operation of Kubernetes. To disable SELinux, edit the /etc/selinux/config file and set SELINUX=disabled. Then, reboot the machine.

Step 3: Install Kubernetes

To install Kubernetes on CentOS, we will use kubeadm. Run the following commands on the master node:

On CentOS 7:

				
					$ sudo yum install -y kubeadm 
$ sudo systemctl enable kubelet 
$ sudo systemctl start kubelet
				
			

On CentOS 8 or CentOS 9:

Install Kubernetes on CentOS, we will use kubeadm. Run the following commands on the master node:

				
					$ sudo dnf config-manager --add-repo=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 
$ sudo dnf install -y kubelet kubeadm kubectl 
$ sudo systemctl enable kubelet 
$ sudo systemctl start kubelet
				
			

Step 4: Initialize the Kubernetes Cluster

On the master node, run the following command to initialize the Kubernetes cluster:

				
					$ sudo kubeadm init --pod-network-cidr=192.168.0.0/16
				
			

This command will initialize the Kubernetes cluster and create a new configuration file at /etc/kubernetes/admin.conf. Copy this file to your home directory with the following command:

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

Step 5: Join Worker Nodes to the Cluster

On the worker nodes, run the following command to join them to the Kubernetes cluster:

				
					$ sudo kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash <hash>
				
			

You can get the values for <master-ip>, <master-port>, <token>, and <hash> from the output of the kubeadm init command on the master node.

Step 6: Install a Network Add-on

To enable networking in the Kubernetes cluster, we need to install a network add-on. We will use the flannel network add-on, which provides a simple and efficient network for Kubernetes.

Run the following command on the master node to install the flannel network add-on:

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

Step 7: Verify the Kubernetes Cluster

To verify that the Kubernetes cluster is running, run the following commands on the master node:

				
					$ sudo kubectl get nodes 
$ sudo kubectl get pods --all-namespaces
				
			

These commands will show you the status of the nodes and the running pods in the cluster. That’s it! You now have a fully functional Kubernetes cluster running on CentOS 7, 8 or 9.

Kubernetes Cluster Install on CentOS: Compare and Contrast

Comparing Kubernetes to Other Container Orchestration Platforms

Kubernetes is not the only container orchestration platform on the market. Other popular platforms include Docker Swarm and Apache Mesos. Here are some key differences between Kubernetes and these other platforms:

  1. Kubernetes is more complex than Docker Swarm and Apache Mesos. It provides a more robust set of features for managing containerized applications, but it also has a steeper learning curve.

  2. Kubernetes is more scalable than Docker Swarm. It can handle larger clusters with more nodes and more containers.

  3. Kubernetes is more flexible than Apache Mesos. It can run on a wider range of operating systems and can be customized to meet specific needs.

  4. Kubernetes has a larger and more active community than Docker Swarm and Apache Mesos. This means that it has more support and is more likely to be updated and improved over time.

Conclusion

Kubernetes is a powerful container orchestration platform that provides a scalable and fault-tolerant environment for running containerized applications. Installing Kubernetes on CentOS is a straightforward process that can be done using kubeadm.

With Kubernetes, you can easily manage complex applications and scale them up or down as needed. Compared to other container orchestration platforms, Kubernetes provides a more robust set of features and a larger and more active community.

Was this article helpful to you? If so, leave us a comment below. We’d love to hear from you!

Related Posts

Leave a Reply

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