Today.

Matthew Mihok posted:

Kubernetes Introduction


In a nut shell from their documentation:

Kubernetes is an open-source platform for automating deployment, scaling, and operations of application containers across clusters of hosts.

It's a way of abstracting away the idea of servers and physical machines. This became appealing to me in devops, particularly to allow developers to build what they need to and not worry about anything else.

I always like to see what versions a blog post is working with in case there are small discrepancies or issues, so we'll be working with:

  • Vagrant 1.8.3
  • Ubuntu 14.04
  • kubernetes 1.2.0

Setting it up on a set of machines isnt too difficult I'll run through the steps that I did to build my own Kubernetes cluster going:

1. Download Kubernetes onto your laptop
$ git clone --branch=release-1.2 \ https://github.com/kubernetes/kubernetes.git

(Note: You should take the most recent stable release, at the time I wrote this it was 1.2.0-alpha.7, I've since updated it to use release-1.2 for posterity)

2. Download the binaries
$ cd kubernetes/cluster/ubuntu
$ ./download-release.sh
3. Use Vagrant to setup your 3 machines really quickly

Or some other way (DigitalOcean, AWS, virtualbox, etc)

I've put up my Vagrantfile gist as an example. The two key pieces here are getting the IP's of each machine and setting up an ssh key for them as well.

4. Update environment variables

Inside the Kubernetes repo you just cloned edit cluster/ubuntu/config-defaults.sh file. There are several options that you may want to change but the key ones will be:

export nodes=${nodes:-"[email protected] [email protected]   [email protected]"}

And:

role=${role:-"ai i i"}

The nodes variable in this code block is the list of machines, their ordered based on the pattern in the role variable. a represents a master machine, and i represents a minion. So in the below case, the first node is a master/minion combo and the rest are just minions.

The next you can either leave and provide before the next step or modify these lines as well:

export SERVICE_CLUSTER_IP_RANGE=${SERVICE_CLUSTER_IP_RANGE:-172.20.1.0/24}

And

export DNS_SERVER_IP=${DNS_SERVER_IP:-"172.20.1.53"}

Note that the DNS_SERVER_IP, and SERVICE_CLUSTER_IP_RANGE is not the same subnet as the $nodes (the vagrant machine IP's.)

5. Install everything on the machines
$ cd ..
$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh

This will install all the necessary binaries on each of the instances created in step 3. The last step will then install the Kubernetes UI tool:

$ ./ubuntu/deployAddons.sh

That's it! Now you can check out the Kubernetes dashboard at http://172.20.0.101:8080