Rancher: Part 2 - Catalogs

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.

Default 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.

screenshot of Catalog

Deploying my First Stack

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" Create a Volume

The next thing to do was to find Jenkins in the catalog. Typing "jenkins" in the search field filtered the selection down to what I wanted. screenshot

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". filled in screenshot of jenkins deployment

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. screenshot of Stacks after Jenkins Deployment

Clicking the port number on the Stack details launches the Jenkins UI. screenshot of jenkins

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. screenshot of synology browser

There's only one problem with this:

  • I know I can go into Rancher and click on the Jenkins port number to launch the UI, but what if I just want to open the UI directly? I know it's on port 8080, maybe I won't forget that? What host is it on though? Remember that I setup 3 hosts to run workloads; which one is hosting Jenkins? I can use the Rancher UI to find all this information but I have a better approach.

Setup a Load Balancer

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.

Wildcard DNS

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.

Create the Load Balancer

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. screenshot

Going back to "Stacks"->"User", I adding a new stack called "load-balancer". The only configuration I did was to give it a name. screenshot

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:

  • Give the Load Balancer a name. I picked "global-load-balancer"
  • Define the "Port Rule" for Jenkins.
    • Access = Public
    • Protocol = HTTP
    • Request Host = jenkins.vip.aceshome.com
    • Port = 80
    • Target = select the jenkins-ci service from the drop down
    • Port = 8080 (This is the port Jenkins is listening on)
  • At the bottom of the form is a tab called "Scheduling". This controls where Rancher will put the load balancer. We need to tell it to put the load balancer on the host that has the label we just created.
    • Condition = must
    • Field = host label
    • key = loadbalancer.enabled
    • value = true
  • Press the Create Button screenshot

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.

Next Up...

Private Catalogs