You had your first k8s master server, now it’s time to setup our nodes and connect them.
Let’s start on Kube1 (192.168.1.34)
$ sudo su- Disable swap
$ swapoff -aAlso don’t forget to disable swap on reboot, by edit /etc/fstab file
- (Optional) Set hostname
$ hostnamectl set-hostname kube1- (Optional) Set static IP
Edit file /etc/netplan/50-cloud-init.yaml to set static IP
network:
renderer: networkd
ethernets:
ens33:
dhcp4: no
addresses: [192.168.1.34/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
version: 2- Update apt
$ apt update- Install Docker
$ apt install docker.ioAuto start Docker
$ systemctl enable dockerStart Docker
$ systemctl start docker- Install Kubeadm
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add
$ apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
$ apt install kubeadm- Join this node to the master
This command was generated when you setup your Master server
$ kubeadm join xxx:6443 --token xxx --discovery-token-ca-cert-hash xxx- (Optional) Docker registry
As I told, for some funny security reasons, Docker doesn’t want to connect to an insecure registry.
To allow Docker to use insecure registry, you need to:
Edit file /etc/docker/daemon.json
{
"insecure-registries" : ["192.168.1.33:5000"]
}Edit file /etc/default/docker
DOCKER_OPTS="--insecure-registry 192.168.1.33:5000"Restart Docker
$ service docker restartRepeat the same, for Kube2 (don’t forget the hostname and static IP)
Now you have a working k8s cluster with Master and 2 Nodes!
In the final chapter, we will build our infrastructure on this cluter. And trust me, it’s not harder than playing with Lego blocks

…To be continued
Final chapter: https://www.martinpham.com/2019/12/14/having-fun-with-kubernetes-final/
