Nedtes

My ideas, thoughts and questions, but mostly just software

Installing Kubernetes on Single Node OVH Server

I recently had to setup a single node kubernetes cluster on OVH. It was mostly for learning purposes. It’s strongly recommended against having a single node cluster in production with kubernetes. I will be using a 4GB RAM dedicated server to for this tutorial. It’s recommnded to have enough room for your intended pods to run.

Assuming that you have a fresh server, first of all, let’s get started by installing Docker on your server.

1
2
3
4
5
6
7
8
9
sudo apt-get update
# Install kernel extra's to enable docker aufs support
sudo apt-get -y install linux-image-extra-$(uname -r)

# The official docker install script
wget -qO- https://get.docker.com/ | sh

# Add user to the docker group. To allow sudoless use of Docker
sudo usermod -aG docker $USER

You need logout and login again. Now you can test your docker install by running the hello container.

1
docker run hello-world

If you get a hello-world text from docker. We are good to continue.

Now we are going to install kubernetes on the server.

1
2
3
4
5
sudo apt-get update && sudo apt-get install -y apt-transport-https
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main"| sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl

Now we have kubernetes installed. We need to initialize our cluster

1
sudo kubeadm init --pod-network-cidr=10.244.0.0/16

Configuring our kube config which is used for authentication inside cluster operations is next.

1
2
3
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

In order for the pods to communicate between them effectively. We will need a networking layer for our cluster. We will be using flannel (developped by coreos) in this tutorial.

1
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Master nodes doesn’t allow pods to run inside it by default. So we need to disable that, since we only have one node that we want to run everything.

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

You can now run your pods on this single node cluster for learning and experimenting with kubernetes.

Here’s the full script that you can use to setup the single cluster node: gist