RANCHER – create a rancher cluster on ubuntu 16.04

I think Rancher is a amazing tool to manage docker containers. It ships with an internal orchestrator: cattle.

This is the way I used to create a cluster of rancher servers.

rancher-01:
eth0 (public interface): 10.209.113.32
eth1 (internal interface): 10.0.0.101

rancher-02:
eth0 (public interface): 10.209.113.33
eth1 (internal interface): 10.0.0.102

rancher-03:
eth0 (public interface): 10.209.113.34
eth1 (internal interface): 10.0.0.103

Make sure you can login to other servers without being prompted for password

 

Mysql Cluster

First of all we need a mysql cluster. Rancher server relies on it to store all the configurations, containers logs, and so on. I preferred to deploy a cluster directly on ubuntu and not on docker because it’s a critical point of failure and docker containers are too mush simple to delete 😀

On all nodes:

We have installed, stopped and remove from automatic startup mysql.

Replace mysql configuration with the following (/etc/mysql/mysql.conf.d/mysqld.cnf)

Now before move on, we need a shared storage. I used GlusterFS for its simplicity. We’re going to setup a GlusterFS cluster that will share some disk for mysql and rancher. On my virtual machine I have a supplementary disk of about 500GB. I will create 10GB disk for Mysql, 450GB disk for rancher and leave the rest for future needs.

On all hosts:

Install gluster server

Edit hosts file (/etc/hosts)

Now create the disk for gluster

Add it to fstab (/etc/fstab) to mount it at boot time

Create the directory taht will be exported by gluster

Create the mount point for the gluster client

 

On the master server:

Create the cluster for gluster

Create a distributed replicated volume

Before create the cluster we need to initialize mysql on the new datadir

Now move on with the cluster

On the other two servers

On the master node

Edit corosync conf to configure the cluster (/etc/corosync/corosync.conf)

Enable pacemaker service (/etc/corosync/service.d/pcmk)

On all nodes

On master node

On master node

connect to mysql cluster and create the db for rancher

HAProxy

Now we need haproxy to load balancing all the requests to rancher servers

On all nodes

On master node

Create a new virtual ip for HAProxy

And one for rancher registration url

 

Rancher

Now it’s time to install rancher in cluster mode

First add the shared disk (you can use it directly from rancher for containers volumes)

On all nodes

On master node

On all nodes

Edit /etc/fstab and insert

Then

 

On rancher-01

On rancher-02

On rancher-03

Now open http://10.209.113.38:8888 and configure rancher. Please keep in mind to set this as registration url for new rancher clients

 

 

Posted in Docker, Rancher, Tutorial.