Illumina Innovates with Rancher and Kubernetes
I showed you how to deploy a Highly Available Wordpress installation
using Rancher Services, a Gluster cluster for distributed storage, and a
database cluster based on Percona XtraDB Cluster. Now I’m going one step
further and we are setting Gluster and PXC clusters using Rancher
Services too. And now we are using new service features available on the
DNS service discovery and Label Scheduling. As you will see it’s
becoming even easier and cleaner to build microservices clusters using
Rancher. First of all I am introducing DNS service discovery and Label
Scheduling features, so you can have a better idea about how they help
us when creating our clusters. Thanks to DNS service discovery each
container within a cluster knows about all other containers on the same
cluster. This is fundamental when using software that needs all
cluster nodes to intercommunicate, like Gluster or PXC. By using service
discovery all our containers are able to talk to each other in order to
automatically initialize and configure the cluster. Even more, when you
scale up a service the new containers can join automatically the cluster
because they are also able to know which containers are already part of
it. Label Scheduling allow us to take more control about how to deploy
our containers. For example, you are able to use a set of Docker hosts
to only deploy a certain type of container. In our case, as an example
and in order to show you how Label Scheduling works, we are using some
Docker hosts to only deploy storage containers, other hosts to only
deploy database containers, and a third group of hosts used to
deploy the wordpress containers. This post is divided in these
Before deploying the Wordpress environment you need to satisfy the
following requirements in AWS:
docker run -d -p 8080:8080 rancher/server:v0.23.0-rc6
In Rancher UI, click Infrastructure menu located at top left, then
click Add Host button and confirm Rancher IP.
Then select Amazon EC2 provider and enter the Access Key and Secret
Key that you got before.
Now choose the same Availability Zone and Subnet where Rancher
Server is deployed.
Then select the Security Group named Wordpress that we created
Create two hosts with these options:
Now you have two hosts running. We have defined the target.service label
in order to deploy only Gluster containers on these hosts. Clone one of
the hosts in order to create three more hosts that we are using for
deploying the PXC containers.
Be sure to use these options:
Repeat this last step to create two more hosts for wordpress containers
using these options:
Finally, after everything connects with our Rancher server, you will see
your seven hosts up and running in the Rancher UI.
In Rancher UI click Services menu option located at top left and add a
new project named Wordpress where we are deploying our Highly
Available wordpress environment. Then expand Add… menu and select
Fill these options on Add Service screen:
Expand Advanced Options and fill the following on these sections:
Now start your recently created service.
Wait for containers to be started, then go to Infrastructure again so
you will see them running on storage1 and storage2 hosts as expected. In
a previous step we chose Always run one instance of this container on
every host option. This is because we are using
/gluster_volume:/gluster_volume volume, that is, we are using
/gluster_volume directory on host local disk. In consequence we cannot
start two containers on the same host, because they would use the same
local directory to save their data and would collide.
You can view logs from gluster containers so you will be able to see
that the cluster has been successfully started.
Now add a second service following these instructions:
After starting pxc service your database containers are up and working.
Again, view pxc logs so you can see messages confirming cluster startup.
Back in Infrastructure you will see new pxc containers deployed on
database1, database2 and database3 hosts as expected.
Now, in order to deploy the Wordpress containers add a new service with
Start the wordpress service and check their logs to confirm they have
successfully started. If you take a look in Infrastructure section you
will see new containers deployed on wordpress1 and wordpress2 hosts. At
this point you must have all your services up and running.
Now it is time to create the Wordpress Load Balancers. We are creating a
total of three Load Balancers. Add a new Balancer Service with this
At this point you have a total of 4 services up and running on Wordpress
project, including the Load Balancer.
Now go to Infrastructure section and copy the IPs of those hosts where
Lb Agents are running. Create a domain that resolves these IPs, or edit
your /etc/hosts file to resolve one of them. I am using the domain
http://myblog.com for testing. Browse to http://myblog.com and
finish the Wordpress installation.
As always you can test the High Availability capabilities. So, for
example, go to Infrastructure section and follow these steps to
simulate host failures:
At this point your Wordpress project should be in DEGRADED status
like shown in the following picture:
Now browse to http://myblog.com/wp-admin/ and your wordpress site
should be working yet. Then back in Host section create again
storage1, database1 and wordpress1 hosts. Wait for new containers to be
automatically created and running.
Rancher has improved and added new services features. The most important
changes with the Rancher beta version are:
As you can see it’s now even easier and cleaner to deploy our
applications as Rancher services. We have also played with service
linking to interconnect all our application stack, that way wordpress is
connected to storage and database services. If you’re interested in
downloading the Rancher beta, visit the
Rancher GitHub site for
instructions. You can find out more about the new beta program
here. Manel Martinez is a Linux
systems engineer with experience in the design and management of
scalable, distributable and highly available open source web
infrastructures based on products like KVM, Docker, Apache, Nginx,
Tomcat, Jboss, RabbitMQ, HAProxy, MySQL and XtraDB. He lives in spain,
and you can find him on Twitter