Welcome to part 2 of a multi-part series where I will walk through the setup and configuration of Rancher.
In the previous post, I walked through the installation of Rancher, deploying the server and 3 hosts that can run dockerized workloads.
In this post I will show you what I think is a major advantage of Rancher, the concept of Catalogs.
Rancher comes with two catalogs enabled. One is called "Library" and is maintained by Rancher, the other is called "Community" and is maintained by the community. The main difference is that the items in the Rancher maintained "Library" are all certified to work. The others should work but things do break occasionally. Filters and search criteria help you find what you want pretty easily. After deploying Rancher, I suggest you go in and look around at the wealth of services that be deployed very quickly.
I wanted to test things out so I deployed a Jenkins instance.
Since I wanted data to be persisted on my NAS, I first created a volume by navigating to "Infrastructure->Storage" and clicking the "Add Volume" button. Supply the name of the volume and a description, then press "Create"
Pressing the "View Details" button on the Jenkins tile brought me to a screen where I could provide some configuration information. I gave the Stack a name, and filled in the volume name from what I had just created. The I pressed "Launch".
After a short time, the Stack showed as active. Going to "Stacks"->"User" showed me my Jenkins stack. Note that if you click on the plus icon next to the name of the stack, it will show details. In this case, it showed that Jenkins was running on port 8080.
Great! I spun up a Jenkins instance in record time. To validate that shared storage was really being used, I went to my Synology UI and looked at the share I had created. Sure enough, there was now a directory named the same as my volume and files/directories had been created.
There's only one problem with this:
In order to solve the problem of remembering where Jenkins is, I am going to setup a Load Balancer. If I can simply remember the load balancer location, it can automatically point me to the running Jenkins instance. Additionally, if I decide to scale up the Jenkins stack by adding more Jenkins instances, it will automatically round robin load balance for me. Very cool.
I used a couple of tricks for this. Since I am really bad at remembering port numbers, I wanted an easy way to remember how to get to Jenkins and future services I deploy. The best way for me is to have a unique hostname per service. To accomplish this, I setup a wildcard DNS entry.
I setup a wildcard for '*.vip.aceshome.com' and had it resolve to the IP address of one of my Rancher Servers. Now, whenever I lookup the IP address for anything.vip.aceshome.com, it resolves to the same ip address.
Most home routers don't support wildcarding but I happen to use Amazon's Route 53 which does. I won't go into the details here, feel free to contact me if you need assistance.
Now to create the Load Balancer Stack itself. I only want one load balancer container running so I needed a way to predictably know which host it was running on. In the Rancher UI, I went to Infrastructure->Hosts and edited the Host whose IP address matched the wildcard DNS I setup. I added a label called "loadbalancer.enabled" and set the value to "true". I could have called the label anything, that's just what I chose.
Back at the list of User Stacks, I selected the little down arrow next to the "Add Service" button on the load-balancer stack. From that, I chose "Add Load Balancer". This brings up a rather intimidating form but it's really not too hard. Here is what I provided:
After a short time, the Load Balancer should show as active.
Now, when I open a broswer and navigate to http://jenkins.vip.aceshome.com the request will go to the Load Balancer who will forward it on to Jenkins, wherever it is running! If more than one copy of Jenkins is active, it will automatically load balance it for me.