I haven’t written any posts from July since I’ve changed my job and started working on something new. Check my about page for more information.
The new work requires me to work with Docker, Docker Swarm, Kubernetes. I’ve worked on Swarm around 2 months before working on Kubernetes.
In my opinion, Kubernetes is more mature than Docker Swarm, but it still has been heavily developed. If you would like to play around with Kubernetes, I would suggest you to firstly start with Docker, then Docker Swarm. Since it’s very easy to setup a Docker Swarm cluster and you could get familiar with it before moving to Kubernetes.
Setup a Kubernetes cluster on Ubuntu 16.04 could be easy or difficult up to the way you choose. I’ve tried with two ways:
With the first method, everything is pretty easy, you just follow the instructions and it should work. At the beginning, I used the first method since it was very quick for me to have a workable deployment. You could have a kubernetes cluster in 5-10 minutes with kubeadm.
There are limitations with kubeadm so it’s still in beta phase, not the official one.
For me, problem raises when I want to build a Kubernetes cluster in production. kubeadm, at the moment, couldn’t provide a way to specify some parameters that we want to pass by when setup the cluster. There are many issues on its repository.
So, I decided to use the more natural way: manually set up the cluster. It was not really easy and I faced a lot of problems, since the deploy script for ubuntu provider is currently supported ubuntu up to version 14.04 while mine is ubuntu 16.04.
So, I would like to describe step by step, how to deploy a Kubernetes cluster on Ubuntu 16.04. For building a cluster in production, you should work around the documentations of kubernetes for more insights.
- Assume you have two ubuntu 16.04 nodes: node0@kube-node0, node1@kube-node1. Let’s take node0 as the master, node1 as a node (or minion).
- Make sure you can ssh passwordless to node0 and node1 from node0.
- Make sure you’ve already installed docker on these two machines.
- Make sure to synchronize time between your machines or you could get some error related to the certificates later on.
We could start from there:
- Clone the repository.
- Remember to set KUBE_VERSION, ETCD_VERSION, FLANNEL_VERSION, here, I use 1.4.7 for KUBE, 2.2.5 for ETCD and 0.5.5 for FLANNEL.
- Configure the default-config.sh file in ubuntu folder. You could take a look there.
- What’s next? Stand in kubernetes/cluster folder and:
I got some errors which took me one day to figure out the solution:
saltbase/salt/generate-cert/make-ca-cert.sh no such file or directory
The deploy script somehow forgot to extract the saltbase zip file, what you need to do is extract the kubernetes-salt.tar.gz and put it into the folder kubernetes/cluster.
./../cluster/ubuntu/util.sh: line xx: yyy: unbound variable
Why did you get this error? Some variables in your configuration file have no value at all. So, what you should do is going through the default-config.sh file once again. If you can’t figure out which variables are unset, you could simple put
set +o nounset
on top of the util.sh file and check if it works.
etcd.service unknown, flanneld.service unknown
This is the worse problem I faced. I realized that up to ubuntu 15.04, it switches to use systemd instead of using upstart (which is default in ubuntu 14.04 and lower version). I tried a couple of solutions there: install etcd manually, then using systemctl to make it start, it seemed to work with etcd but didn’t with flanneld. So, I decided to switch from using systemd to using upstart, you could try with and reboot, your ubuntu will switch to upstart.
sudo apt-get install upstart-sysv sudo update-initramfs -u
Those were not all the problems I faced, but those were the ones took me so much time.
What’s next? Install addons for your cluster: dns and dashboard by running
in ubuntu folder and I think you could have a running kubernetes cluster up to this step.
Anyway, this is not the end of the story, there’s a ton of things we need to have on this Kubernetes cluster. I would like to talk about them in other posts. [By the way, this could be my last post in this year]. Hopefully I could have more time and interesting things to write on next year.
Feel free to comment or contact me!