During my time working at Azoi (a startup), I was responsible for maintaining Gitlab for my team along with various other self-hosted internal services. When I first setup Gitlab in 2013, it was quite a task, as setting it up would involve configuring various services using provided scripts and a lot of luck. Fortunately, I found Bitnami Gitlab package to make that process easier. However initial setup is one thing and keeping up with the latest releases was a nightmare.
Fast forward to 2016, I joined eInfochips as Solutions Consultant. Where one of my responsibilities was to modernize development workflow and encourage DevOps culture. It made sense to use Gitlab specially for Gitlab-runner and since this was a fresh setup, I explored few options to setup Gitlab, I found that Gitlab monthly releases were now published as Docker images. So I decided to use Gitlab docker image to host gitlab-ce internally. This time around, the experience was very different, initial setup and upgrading Gitlab was almost instant and painless.
I was quite impressed with this mechanism and got an opportunity to set up a similar mechanism for delivering a project I was working on. I quickly set up a local private docker repository and CI pipeline using Gitlab-runner to build and push few spring-boot based micro-services on docker registry. And used Rancher (more on it later) to deploy it on different environments (Dev, QA, Prod). It worked like charm.
That brings me to Kubernetes. Having read a lot about it, I gave it a try and back then it wasn’t easy to set up as there were not many helper utilities like kops. Rancher, on the other hand, had built-in support for setting up Kubernetes cluster. Setting up Rancher is as simple as running a docker container. I had a great experience with Rancher and would like to share how easy it is to use it for deploying services and getting yourself familiar with Kubernetes.
So that brings us to what exactly is the role of Rancher, as container scheduling is handled by Kubernetes. Rancher is a cluster management tool, it allows you to set up and manage multiple Kubernetes cluster. It supports multi-cloud backends, authentication, access control, and a nice UI using which you can deploy and manage your containers. It also allows you to import existing cluster made on GKE or Amazon EKS.
I’ll focus on Rancher 2.0, the latest version at this moment. Setting it up is a 2 step process. First is to install Rancer-Server and second is to install Rancher-Agent on worker nodes. I used 3 Ubuntu Server (18.04) boxes with Docker to set it up. One box runs Rancher Server and 2 boxes are workers which will run our containers (along with few Kubernetes services).
On Machine 1, run following command to start Rancher-Server, it should be up within a minute and you should be able to access web UI on port 443.
sudo docker run -d –restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher
Beauty of Rancher is that you don’t have to be familiar with Kubernetes, it sets up cluster transparently.
Rancher 2.0 - Login Screen
Set admin password, and proceed to create a new cluster by clicking “Add Cluster” button.
Choose infrastructure provider, in my case I used local machines as nodes so I selected “Custom” however if you provide API key for GCP/AWS/Azure etc, Rancher will instantiate required compute resources for you!
Now to set up nodes for our cluster, start one node with “etcd”, “Control Plane” and “Worker” as roles. Additional nodes can be added with only “Worker” role.
Rancher will generate a docker run command which you can run on your nodes to make them part of the cluster. This will start rancher-agent on nodes and will set up Kubernetes services. It can take a couple of mins to show these nodes as active on your cluster. At this point, you should be able to see your cluster health and resource utilization. I highly recommend exploring catalog apps to get yourself familiar with Rancher.
I hope this helps you get started with Rancher, in my next post I’ll write more about how you can deploy your app on Rancher and perform upgrades and rollback.