How to install Kubernetes on Centos 8 (Redhat 8)

Install docker:

$dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
$dnf install docker-ce --nobest -y
$systemctl start docker && systemctl enable docker

Disable Firewall:

$sudo systemctl stop firewalld && sudo systemctl disable firewalld

Install Kubernetes:

add new repository:

$sudo nano /etc/yum.repos.d/kubernetes.repo
[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

 Install the necessary Kubernetes packages with the command:

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

Start and enable the service with the command:

sudo systemctl enable --now kubelet

Configure iptables:

nano /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

reload the new configuration with the command:

sysctl --system

Disable Swap:

We temporarily disable swap by command:

$sudo swapoff -a

To permanently disable swap (so it’s not re-enabled upon reboot), open the fstab for editing with the command:

$sudo nano /etc/fstab

comment out (add a # character at the beginning of a line) the line that begins with:

#/dev/mapper/cl-swap

Create a Daemon File:

$nano /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"
  ]
}

Create a new systemd directory with the command:

$mkdir -p /etc/systemd/system/docker.service.d

Reload and restart the Docker daemon with the commands:

systemctl daemon-reload && systemctl restart docker

Initialize the Kubernetes Cluster

This is only done on the Kubernetes master. To initialize the cluster, issue the command:

$sudo kubeadm init

after that there should be information how to join this machine (node workder) to cluster by command

 $kubeadm join.....

we can check it by this command:

$kubectl get nodes 

for a single-machine Kubernetes cluster we need to enable scheduling Pods on the control-plane node, which is disabled by default.

$kubectl taint nodes --all node-role.kubernetes.io/master-

Deploying the Dashboard UI

official guide here.

$kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
Accessing the Dashboard UI

configuration for outside accessing is here.

checking the deployed status:

$kubectl get pods --all-namespaces
$kubectl describe pod NAME

Leave a Reply

Close Menu