Translate

Use categories on the left bar

For orientation in my website, please use a left menu bar with category/subcategory list

Kubernetes -Preparation (CentOS 8/RHEL)

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 /RHEL8 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

Edit features

Add CSIMigration to false in the end of this file
vim /var/lib/kubelet/config.yaml
featureGates:
  CSIMigration: false
Edit this file:
/etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}

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.

No comments:

Post a Comment