sudo apt-get update && sudo apt-get upgrade -y

--------- INSTALL DOCKER ---------
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER

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

sudo vim /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main

sudo apt-get update

----- Installing Kubeadm ----
sudo apt-get install -y kubelet=1.20.2-00 kubeadm=1.20.2-00 kubectl=1.20.2-00

# The kubelet is now restarting every few seconds, as it waits in a crashloop for kubeadm to tell it what to do.
sudo apt-mark hold kubelet kubeadm kubectl

# because it swap mem can degrade K8s orchestration performance
sudo swapoff -a

------- on MASTER Node ---------
sudo kubeadm init

# if success, you will get a join command to bind the worker nodes with the master's api-server listening on port 6443
# ::WARN:: make sure your worker nodes can connect to the api-server on port 6443

# Check if the Control Plane Containers are started or not
sudo docker ps

------ on WORKER Node -----
# Run the example command bellow according to your inputs
# sudo kubeadm join <master-node-ip>:6443 --token <token_id> \
# --discovery-token-ca-cert-hash sha256:<fingerprint>

------ on Master Node -----
#get all worker nodes and check the state.
kubectl get nodes
# you will see the master and workers are in notReady state. Means they have no internal overlay networking enabled.

# To achieve Overlay Network inside the K8s Cluster, we are going to install WeaveNet on Master node.
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

#get all worker nodes
kubectl get nodes

#get all pods
kubectl get pods -A