Install Kubernetes
==================
This part of the installation is carried out on all nodes.
Perform updates and upgrades:
```bash
apt -y update &&
apt -y full-upgrade --auto-remove &&
apt -y upgrade
```
Install, enable and start Docker:
```bash
apt install -y docker.io &&
systemctl start docker &&
systemctl enable docker
```
Install Kubernetes:
```bash
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add &&
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list &&
apt -y update &&
apt install -y kubelet kubeadm kubectl kubernetes-cni
```
Master node
-----------
This part of the installation is carried out on the **master node only**.
Initialise the master node. If the non default IP address should be used, such as for routeing the cluster node in the same datacenter using private IP addresses, then `--api-advertise-addresses` should be added:
```bash
kubeadm init --apiserver-advertise-address PRIVATE_IP
```
Copy the join command outputted (i.e.`kubeadm join ...`) so that worker nodes can join later on, then create a non-priveledged user as the output suggests (replacing `PASSWORD` as appropriate):
```bash
useradd kubernetes -G sudo -m -s /bin/bash &&
echo "kubernetes:PASSWORD" | chpasswd
```
Copy the config (password required for `sudo`):
```bash
su kubernetes &&
mkdir -p $HOME/.kube &&
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config &&
sudo chown $(id -u):$(id -g) $HOME/.kube/config
```
May not be needed now and Flannel shouldn't be used without giving args on init above. Deploy a CNI (container network interface) to deploy pods to the cluster. `Flannel` is used here, but other [cluster network technologies](https://kubernetes.io/docs/concepts/cluster-administration/networking) are avalible.
```bash
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml &&
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
```
### Optional
By default pods can't be deployed on master nodes. To allow pods on master nodes and also allow a single node deploy:
```bash
kubectl taint nodes --all node-role.kubernetes.io/master-
```
References
----------
- https://kubernetes.io/docs/setup/independent/install-kubeadm
- https://linuxhint.com/setup-kubernetes-digitalocean
- https://www.techrepublic.com/article/how-to-quickly-install-kubernetes-on-ubuntu
- https://medium.com/@Grigorkh/install-kubernetes-on-ubuntu-1ac2ef522a36
- https://www.mirantis.com/blog/how-install-kubernetes-kubeadm