Docker orchestration with Kubernetes and Rancher

When it comes to Docker containers and orchestration there are a lot of available options. Almost every few months some new Docker orchestration tool is available. At least that was the case at the beginning. Most of those tools are opensource projects, but of course, there are some enterprise orchestration tools. However, Google’s Kubernetes is most used and really popular tool. Like with all Google products it is also complicated to install and manage. They recently released kubeadm Kubernetes deployment tool, but this is still in Alpha and not ready for production environments. In this post, I will show you how to deploy Kubernetes on top of Rancher which is my favorite. With Rancher, you could decide which Docker orchestration tool to use, like Cattle (Rancher), Kubernetes, Mesos or Docker Swarm.

Rancher deployment on AWS

Seven months ago I discovered Rancher. I really liked it and I decided to make an automated deployment with SaltStack https://github.com/komljen/rancher-salt. This deployment procedure is also available from official Rancher installation docs on Github if your tool of choice is SaltStack https://github.com/rancher/rancher#installation.

First, I created vagrant provisioning and then added a support for AWS. For AWS I decided to make a Docker container which will work on any OS (Mac, Windows or Linux) and the only dependency you will need for this is Docker engine installed and running. komljen/salt-cloud image has all dependencies already installed, like salt-cloud, awscli and custom scripts to prepare configuration files.

All you need to do now is to run Docker container using your AWS access and secret keys:

After a few seconds you can check logs for this container and if last message is ‘Keep this container running…’ you can connect to it:

Kubernetes provisioning on Rancher

Now you can start VM provisioning on AWS. Salt master will start first and then all minion nodes will start in parallel. They will be connected to master automatically. To select which node will also be a Kubernetes node edit this file /etc/salt/cloud.maps.d/rancher.conf and update agentEnvironment value to Kubernetes. Default means Rancher Cattle environment. Each Rancher agent node can be used by only one environment at the same time. Run below command to start a VM provisioning:

When all nodes are ready we can connect to master node and finally start Rancher provisioning. You can connect to master node using newly created pem key /etc/salt/salt_cloud_key.pem directly from a Docker container. Check your master public IP address with:

Check the environment and if all minions are connected, start Rancher deployment:

To access Rancher web UI at http://AWS_MASTER_PUBLIC_DNS:8080 you need to open 8080 port on master node. Also, as Rancher agents are added to Kubernetes environment, Kubernetes deployment will start automatically.

Managing Kubernetes resources

When Kubernetes is deployed with Rancher you have multiple options to manage it. Rancher also deploys Kubernetes dashboard and kubectl is available from the web. If you prefer to use kubectl on your workstation it is possible to generate ~/.kube/config file. On top of that Rancher monitors all Kubernetes services and it’s versions:

If you want to try this you can easily run multi node Vagrant environment by instructions described here https://github.com/komljen/rancher-salt.

Follow me

Alen Komljen

DevOps Engineer at Cron
Focused on building and automating infrastructure. My toolbox: Docker, Kubernetes, Rancher, Terraform, SaltStack, Ceph, OpenStack, Linux, AWS, GCE and many others.
Follow me

Latest posts by Alen Komljen (see all)

Tweet about this on Twitter43Share on Facebook27Share on LinkedIn7Share on Google+0
Alen KomljenDocker orchestration with Kubernetes and Rancher