HomeLab Kubernetes

Pre-Reqs

  • One master node
    • kube01 - 172.29.14.13
  • Two worker nodes
    • kube02 - 172.29.14.14
    • kube03 - 172.29.14.15

All Nodes

OS Config

sudo su -

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

swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

Docker Install

modprobe br_netfilter
echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
yum remove -y podman-manpages
dnf install -y docker-ce
systemctl enable --now docker

KubeAdm Install

cat <<EOF > /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
EOF
dnf install -y kubeadm 
systemctl enable --now kubelet

Master Node

Kube Master Setup

firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --add-port=2379-2380/tcp
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=10251/tcp
firewall-cmd --permanent --add-port=10252/tcp
firewall-cmd --permanent --add-port=10255/tcp
firewall-cmd --reload
kubeadm init

Make a note of the master join command:

kubeadm join 172.29.14.13:6443 --token 0zuyh2.fhhp5osbpwjyfza5 --discovery-token-ca-cert-hash sha256:112eb1b2b5d28d56de76be9066e6f96acdff8103a889568a76c996508291e923
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config

Verify:

kubectl get nodes

Pod Network

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

I had a problem with the Weave containers.

kubectl delete -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
curl -L git.io/weave -o /usr/local/bin/weave
chmod a+x /usr/local/bin/weave
weave reset
rm /opt/cni/bin/weave-*
weave setup
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

Worker Nodes

Do all of the steps in the common section above.

firewall-cmd --permanent --add-port=6783/tcp
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=10255/tcp
firewall-cmd --permanent --add-port=30000-32767/tcp
firewall-cmd --reload
kubeadm join 172.29.14.13:6443 --token 0zuyh2.fhhp5osbpwjyfza5 --discovery-token-ca-cert-hash sha256:112eb1b2b5d28d56de76be9066e6f96acdff8103a889568a76c996508291e923

curl -L git.io/weave -o /usr/local/bin/weave
chmod a+x /usr/local/bin/weave
rm /opt/cni/bin/weave-*
weave setup

Verify (on the master):

kubectl get nodes

References

TecMint - How to Install a Kubernetes Cluster on CentOS 8 The Mori - Errors while deploying weave on kubernetes