At first we have to install docker

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

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

sudo apt update && sudo apt install docker-ce

With docker installed we have to disable swap on our system as mentioned in the changelog.

sudo swapoff -a

sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

The aforementioned command comments out all swap entries in the /etc/fstab file.

Now we have everything prepared to create a single node Kubernetes cluster (version 1.12.1) with kubeadm.

sudo apt-get update && sudo apt-get install -y apt-transport-https && curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list && sudo apt-get update

sudo apt install -y kubeadm  kubelet kubernetes-cni

With kubeadm installed we have to initialize our master. A full description is available on the Kubernetes documentation

You can specify the Kubernetes version using the –kubernetes-version=v1.12.1 flag.

A list of available versions is on their github repo.

With the –apiserver-advertise-address=192.168.1.254 flag you can specify the ip address on which the Kubernetes api server listens.

A list of available flags for kubeadm init is available on the Kubernetes documentation.

sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.1.254 --kubernetes-version=v1.12.1

The end of the output should contain the command for joining other workers. It looks something like the following command.

kubeadm join 192.168.1.254:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>

To make kubectl work for your non-root user, run the following commands.

mkdir $HOME/.k8s

sudo cp /etc/kubernetes/admin.conf $HOME/.k8s/

sudo chown $(id -u):$(id -g) $HOME/.k8s/admin.conf

export KUBECONFIG=$HOME/.k8s/admin.conf

echo "export KUBECONFIG=$HOME/.k8s/admin.conf" | tee -a ~/.bashrc

We also need to install a networking model for Kubernetes. A detailed description is available on the Kubernetes documentatoin.

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

To use the master also as a worker we have to run the kubectl taint command, which allows pods to be scheduled to run on the Kubernetes master server. A detailed description is available on the Kubernetes documentation.

kubectl taint nodes --all node-role.kubernetes.io/master-

Now we have a single node Kubernetes cluster running on Ubuntu 18.04.1 (Bionic Beaver).

To deploy the dashboard see my other post deploy Kubernetes dashboard.