s0x IT Services Cloud How to install Kubernetes on CentOS 8

How to install Kubernetes on CentOS 8

How to install Kubernetes on CentOS 8 post thumbnail image

With CentOS 8 out, the installation of Kubernetes has changed. Learn how to make this happen.

CentOS 8 has arrived, and along with it a number of changes have been discovered. One such change is how the installation of the Docker engine and Kubernetes is taken care of. I’ve already covered the  installation of Docker CE on Cent OS 8 , and now I want to walk you through the process of installing Kubernetes on the same CentOS 8 server.

SEE: Hybrid cloud: A guide for IT pros (TechRepublic download)

What you’ll need

To make this work, you’ll need the following:

  • A running instance of CentOS 8
  • Docker CE installed and running
  • A user with sudo privileges
  • Access to the root user

How to install Kubernetes 

Remember, it’s crucial that you have Docker CE installed, before starting this process. Once you have the Docker engine up and running, here’s how to add Kubernetes to the server.

The first thing to be done is the addition of the Kubernetes repository. To do this, open a terminal window on the CentOS 8 server and issue the command:

sudo nano /etc/yum.repos.d/kubernetes.repo

In this new file, paste the following contents:                   

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

Save and close the file.

Next, install the necessary packages with the command:

sudo dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

Enable the kubelet daemon with the command:

sudo systemctl enable --now kubelet

For the next task, you must su to the root user. Once you’ve done that, issue the command:

nano /etc/sysctl.d/k8s.conf

In this new file, add the following two lines:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

Save and close the file.

Reload the configuration with the command:

sysctl --system

Exit out of the root user with the command:

exit

How to disable swap

Finally, before you initialize your Kubernetes cluster, you must disable swap. For this, issue the command:

sudo swapoff -a

To make this permanent, issue the command:

sudo nano /etc/fstab

Comment out the line that starts with /dev/mapper/cl-swap     swap. Save and close the file.

You can now initialize your Kubernetes cluster and add nodes. Your CentOS 8 Kubernetes server is ready to start deploying.

Also see

kuberneteshero.jpg

Image: Jack Wallen

Related Post