Asumptions and Clarifications

We are going to install a worker node

You already installed a master node using first part as guide

most of the steps are the same but we will repeat them just in case

Installing

1. Preparing the node

As we mentioned we are going to install Docker as Runtime for that we need several tools that are not included with the OS by default

Install packages to allow apt to use a repository over HTTPS

 sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common -y

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

Add the Docker apt repository:

 sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"

Install Docker CE

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y

Set up the Docker daemon

cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

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

Restart Docker

systemctl daemon-reload
systemctl restart docker

Disable SWAP

swapoff -a
Remove entry in /etc/fstab of the swap file or partition

2. Installing kubeadm, kubelet and kubectl

Install tools

sudo apt-get update && sudo apt-get install -y apt-transport-https curl

Add Repo GPG Key

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

Add Kubernetes oficial repository

cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

Install packages

sudo apt-get update -y
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

Download containers images to deploy the cluster FYI: each service will run in a container inside the master nodes

kubeadm config images pull

Setup kubernetes (add a worker node)

at the end of the installation of the master node part1 you will get an output similar to this

You can now join any number of control-plane nodes by copying certificate authorities                                                                             
and service account keys on each node and then running the following as root:                                                                                     

  kubeadm join kubectl.virtualinfra.online:6443 --token 61j6u1.rn4fzbyl68hglrcl \                                                                                 
    --discovery-token-ca-cert-hash sha256:20ffe1a434038676213aabbb89e5d361c28530e549424256b9310ed805a2cb7b \                                                      
    --control-plane                                                                                                                                               

Then you can join any number of worker nodes by running the following on each as root:                                                                            

kubeadm join kubectl.virtualinfra.online:6443 --token 61j6u1.rn4fzbyl68hglrcl \                                                                                   
    --discovery-token-ca-cert-hash sha256:20ffe1a434038676213aabbb89e5d361c28530e549424256b9310ed805a2cb7b                                                        
root@kube-master01:~#

and that’s is the only difference that we need to add a worker node

now you can run this command

kubeadm join kubectl.virtualinfra.online:6443 --token 61j6u1.rn4fzbyl68hglrcl \                                                                                   
    --discovery-token-ca-cert-hash sha256:20ffe1a434038676213aabbb89e5d361c28530e549424256b9310ed805a2cb7b

That’s it

you can now check your new node

#kubectl get nodes
NAME               STATUS   ROLES                  AGE     VERSION
kube-master01.virtualinfra.online   Ready    control-plane,master   4d14h   v1.20.5
kube-worker01.virtualinfra.online   Ready    <none>                 3d14h   v1.20.5

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

https://docs.docker.com/engine/install/debian/

https://github.com/kubernetes/dashboard

https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md