. . .

How to install a Kubernetes Cluster on CentOS 7

Before attempting to produce containerized apps, a strong foundation in Kubernetes, the industry-leading container proportion platform, is typically necessary. CentOS 7 is well-known for its dependability and stability, making it a great host for launching a Kubernetes cluster. This guide, designed specifically for CentOS 7 users, seeks to clarify the installation procedure and offers crucial insights to set up a Kubernetes cluster on CentOS 7. This opens the door for simplified container management, regardless of experience level with containers.

Containers in small virtual environments have proven essential for managing and creating applications. Using an isolated container to work on apps does not affect the host operating system, making them more efficient than virtual computers. Kubernetes, an open-source framework, facilitates the deployment and scaling, as well as the management of resources among several containers.

Required Conditions:

  • CentOS 7 operating on multiple Linux servers (1 Master Node and multiple Worker Nodes)

  • User accounts with root or sudo access on every servers

  • Yum package manager included by default

  • Terminal or command-line window

    Experience the best cloud services in India with a wide range of options including cloud VPS, dedicated servers, Linux VPS, Windows servers, and Tally VPS. Choose from our top-tier solutions to meet your business needs.

Steps to Install Kubernetes on CentOS 7:

To use Kubernetes, you must first install a containerization engine. Docker is currently the most widely used container solution and must be installed on both the Master and Worker Nodes on CentOS.

Step 1: Begin by setting up the Kubernetes Repository on the Master Node and each Worker Node that will be used in your container configuration. The Kubernetes repositories can be accessed by running the following command:

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

Step 2: Proceed with installing kubelet, kubeadm, and kubectl on every node to enable the use of Kubernetes. Execute the following commands to install the necessary packages:

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

With Kubernetes and its essential packages now installed, the system is ready for operation.

Remember to configure hostnames, set up the firewall, and adjust kernel settings before deploying the cluster. Additionally, you can verify the installation of Kubernetes by running the appropriate command.

Step 3: Configuring Nodes Hostname
To assign each of your nodes a distinct hostname, use the following command:

sudo hostnamectl set-hostname master-node

sudo hostnamectl set-hostname worker-node1
In this case, the worker node is named worker-node1, while the master node is named master-node.

To resolve the hostname for every node, create a host entry or DNS record:

sudo vi /etc/hosts
Include the following entries: master.phoenixnap.com master-node node1.phoenixnap.com node1 worker-node

Step 4: Setting Up Your Firewall
For the nodes, containers, and pods in the cluster to communicate with each other, the firewall must be configured. On CentOS, firewalld is enabled by default. Use the following commands to add the necessary ports.

On the Master Node, enter:

sudo firewall-cmd –permanent –add-port=6443/tcp
sudo firewall-cmd –permanent –add-port=2379-2380/tcp
sudo firewall-cmd –permanent –add-port=10250/tcp
sudo firewall-cmd –permanent –add-port=10251/tcp
sudo firewall-cmd –permanent –add-port=10252/tcp
sudo firewall-cmd –permanent –add-port=10255/tcp
sudo firewall-cmd –reload
A “success” message confirms the addition of each port.

Configure the firewall on each worker node with the following commands:

sudo firewall-cmd –permanent –add-port=10251/tcp
sudo firewall-cmd –permanent –add-port=10255/tcp
firewall-cmd –reload

Step 5: Modifying Iptables Configurations
In the Sysctl configuration file, set net.bridge.bridge-nf-call-iptables to ‘1’. This ensures that IP tables handle packets correctly during filtering and port forwarding.

Create a file named k8s.conf in /etc/sysctl.d/ with the following content:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
Run sysctl –system to apply the changes.

Step 6: Disabling SELinux
To allow containers access to the host filesystem, SELinux must be turned off. Use the following commands to disable SELinux.