How to setup Kubernetes with Docker on CentOS 8

Setuping kubernetes with docker on CentOS 8

Step 1 - Disable SELINUX

sudo su
setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/sysconfig/selinux

Setup your hostname

echo "${MACHINE IP HERE} k8s-master" >> /etc/hosts
hostname k8s-master

Enable linux bridge

echo "net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf

Disable swap

Open file

nano /etc/fstab

Then comment all swap lines (/swap)

Restart the VM

shutdown -r now

After VM restart remember to join as root

sudo su

Add Docker repo

dnf install yum-utils -y && yum-config-manager --add-repo

Add kubenerters repo

echo "[kubernetes]

gpgkey=" > /etc/yum.repos.d/kubernetes.repo

Install latest supported docker e kubeadm

dnf install -y kubeadm docker-ce-19.03.15-3.el8 docker-ce-cli-19.03.15-3.el8

Start and enable (startup) docker e kubelet

systemctl start docker kubelet
systemctl enable docker kubelet

Start kubernetes with the follow CIDR

kubeadm init --pod-network-cidr=

The above command can be take up to 5 minutes (depends of the machine/network speed)

After finish, run the command bellow (remember that installation as need inside root user)

echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bashrc
export KUBECONFIG=/etc/kubernetes/admin.conf

Join the node

Execute the join command showed as the result of init. Command example below

kubeadm join --token 938475.896hWdx4AYRpxDWM --discovery-token-ca-cert-hash sha256:SURSqEgFLcNuMzeVXpX5TuT3AAsCrJEdfJLPhU9EePF7NQv82UP3mnUCv9bJAZ2F

If when you run the command above and throw an error, just append on final


Eg final command

kubeadm join --token 938475.896hWdx4AYRpxDWM --discovery-token-ca-cert-hash sha256:SURSqEgFLcNuMzeVXpX5TuT3AAsCrJEdfJLPhU9EePF7NQv82UP3mnUCv9bJAZ2F --ignore-preflight-errors=all

Install flannel

kubectl apply -f

Fix Kubernetes Taint

kubectl taint nodes --all

After run the above command, wait a little time and run

kubectl get nodes

and check if the STATUS is Ready