At first we have to install docker

curl -fsSL | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] $(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 | sudo apt-key add -

echo "deb 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= 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= --apiserver-advertise-address= --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 --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

kubectl apply -f

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

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.