Installation and Configuration of Kubernetes

Installation and Configuration of Kubernetes

Installation and Configuration of Kubernetes

Servers

VM Name Role IP Address CPU RAM Disk
wt-k8s-master01 k8s Master 192.168.77.151 2 8GB 20GB
wt-k8s-master02 k8s Master 192.168.77.152 2 8GB 20GB
wt-k8s-master03 k8s Master 192.168.77.153 2 8GB 20GB
wt-k8s-worker01 k8s Worker 192.168.77.154 2 16GB 20GB
wt-k8s-worker02 k8s Worker 192.168.77.155 2 16GB 20GB
wt-k8s-worker03 k8s Worker 192.168.77.156 2 16GB 20GB
wt-k8s-haproxy01 Load Balancer 192.168.77.150 2 2GB 20GB

Set Static IP in Ubuntu 18.04

sudo su -
cd /etc/netplan
rm 50-cloud-init.yaml
vim 01-network.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    ens18:
      dhcp4: no
      addresses:
        - 192.168.77.151/22
      gateway4: 192.168.76.1
      nameservers:
        addresses: [192.168.77.90]
        search: [weepytests.com]

Run ansible baseline playbook on all machines.

Worker Nodes

Each worker node has a 100GB tier-2 storage attached to them at /dev/sdb

sudo su -
mkfs.xfs /dev/sdb
mkdir /srv/docker
chmod 000 /srv/docker
chattr +i /srv/docker
vim /etc/fstab
*********
/dev/sdb    /srv/docker    xfs    defaults    0 0
*********

mount -a
apt install docker.io -y
systemctl stop docker
cd /var/lib/docker
mv * /srv/docker/
cd ..
rm -rf docker
ln -s /srv/docker/ docker
systemctl start docker
systemctl status docker

Installing k8s Binaries

sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet=1.18.1-00 kubeadm=1.18.1-00 kubectl=1.18.1-00
sudo apt-mark hold kubelet kubeadm kubectl

Note: To unhold, run

sudo apt-mark unhold <binary>

Create a docker daemon.json:

{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}

Disable swap:

sudo swapoff -a

Reference Tutorial