Use these steps to install Kubernetes tools on the master and worker nodes.
$ 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
$ sudo apt-get install kubelet kubeadm kubectl
$ sudo apt-mark hold kubelet kubeadm kubectl
$ sudo swapoff -a
Use these steps on the master node only.
$ sudo su -
$ kubeadm init
$ exit
Use these steps on the master node only.
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
There are many pod network add-ons available. This step uses Calico v1.6. For other options, look here. Use these steps on the master node only.
$ kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
The second command, which actually joins the cluster at a given IP address using a token and a certificate hash, is only an example. When you execute the above commands to create the cluster on the master, the output will provide you with the actual command that you'll need to use. Copy that command from the output on the master and paste it to the command line on each node.
Use these steps on the worker nodes only.
$ sudo su -
$ kubeadm join 192.168.0.1:6443 --token aaabbb.ccccddddeeeeffff --discovery-token-ca-cert-hash sha256:abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01
The token is only valid for 24 hours. If you want to add a new node to the cluster after that period expires, you'll need to generate a new token on the master.
Use this step on the master node only.
$ kubeadm token generate