Skip to content
All articles

From Rancher 1 to Kubernetes at Uala

At Uala, we got used to a particular kind of production failure. Two hosts would stop talking to each other, even though their containers were still running. Restarting a Rancher network agent could get traffic flowing again. We had monitoring to tell us when it happened, and as the fleet grew we spent more time waiting for the next alert.

That was the problem we took into our move to Kubernetes. Before touching the application fleet, we wanted to see what happened when a node disappeared and to know exactly which image our pipeline would put into production.

How Rancher 1 got us to 650 containers

Our first Docker deployment was one frontend on Dokku. About a year later we containerized the backend and moved it from Heroku to three dedicated servers. The machines fit our budget, but Dokku had no easy way for us to manage the three as a fleet. Kubernetes was still changing quickly, and Rancher gave us a way to add machines and deploy across them.

Over about four years, we went from three dedicated servers to 25 and from roughly 20 containers to 650. Backend traffic rose from around 1,000 requests a minute to more than 7,000, with an average response time of about 100 ms when we wrote up the problem.

Rancher 1 used its own orchestrator, Cattle, and network agents built an IPsec network across hosts. When communication between agents became intermittent, services could be reachable from one host and unreachable from another. Sematext gave us visibility into containers and hosts, but it took a restart of the affected agent to recover in those incidents. We stayed with Rancher 1 while the team was busy shipping product features. Rancher 2 gave us a way to keep the management interface while moving orchestration to Kubernetes.

Three machines for the management cluster

The first decision was where to run Rancher itself. Our comparison in 2019 was between a single small EC2 instance and three dedicated servers spread across providers and data centers.

Option What we priced Monthly estimate
One EC2 instance 2 vCPU and 8 GB RAM, plus storage and network ≈ €100
Three dedicated servers One each from Hetzner, SoYouStart and Online.net, with 32–64 GB RAM per host ≈ €119

These were the options we were considering at the time, with different operating trade-offs. For roughly €20 more per month, the dedicated option let us build a three-node cluster for Rancher and left room to experiment with running CI there. We used RKE to create the cluster and Helm to install Rancher. We enabled etcd snapshots every six hours and kept a day of snapshots on the nodes, with off-node copies as a separate task.

What happened when we lost a node

In our first tests, Kubernetes left pods on the lost node in an unknown state for about five minutes before replacing them elsewhere. We changed how often the kubelet reported status, how long the controller waited before declaring a node unhealthy, and how long it waited to evict the pods.

Time to replace pods after losing a node
Observed in our RKE test cluster.
Initial settings≈ 5 min
After tuning≈ 45 s

These were the relevant values from our RKE configuration. The measurements belong to that cluster and that version of Kubernetes.

services:
  kubelet:
    extra_args:
      node-status-update-frequency: 4s
  kube-controller:
    extra_args:
      node-monitor-period: 2s
      node-monitor-grace-period: 16s
      pod-eviction-timeout: 30s

The settings trade recovery time against tolerance for temporary network failures. Waiting less means Kubernetes can replace pods sooner after a real outage, but a brief interruption is more likely to cause them to be moved. Testing an actual node loss gave us a better basis for that choice than watching a healthy dashboard.

Replacing the Jenkins deployment scripts

On Rancher 1, Jenkins ran on a dedicated host. We had custom scripts to build images, run backend tests in Docker, and deploy through a Rancher wrapper. For the new setup we wanted those same capabilities, plus workers we could spread across machines. Moving more than a hundred repositories away from GitHub was outside the scope of the migration.

We considered keeping Jenkins, using the pipeline feature built into Rancher 2, and adopting GitLab CI. Drone fit our setup best. Each step runs in a container, and agents can execute jobs independently of the server. We deployed the Drone server as a Rancher workload and activated repositories in Drone so GitHub events could trigger their pipelines. The full CI/CD setup covers the server, agents and GitHub integration.

The Rancher 2 Deploy Workload screen showing the Drone server image and namespace
From the original 2019 series. The Drone server ran as a workload in its own namespace.

What happened after a push

The Rails backend went first. A branch build published two tags for the same image. We reused the branch tag as the cache source on the next build. The branch-and-commit tag identified the exact image that RuboCop and RSpec would use in parallel.

Backend pipeline for a branch push
  1. BuildPublish a cache tag and a commit-specific image tag.
  2. CheckRun RuboCop and RSpec in parallel with that image.
  3. DeployUpdate the workloads mapped to the branch’s test environment.

We had ten test environments. A branch could be assigned to one so developers, testers and product managers could see the same version. Our Drone plugin for Rancher read a configuration file that mapped branches to a Rancher project, Kubernetes namespace and list of workloads. That let Drone run in one cluster and deliver the image to another. The deployment identity only needed access to manage workloads in its assigned projects. The original pipeline article includes the YAML for each stage.

What we required for production

A release tag had to point to a commit on master, and the registry had to contain a master image for that exact SHA. A tag build could then use the already-built image as a cache source rather than starting from scratch. Test and production deployments used separate Rancher identities, and our production credentials were available only for tag events.

The pipeline file itself lived in the repository. A branch could change that file, including the checks we relied on. Drone’s protected-repository setting let us require a signed pipeline definition so unauthorized changes to that definition would stop the build.

Drone repository settings showing the Protected option and the .drone.yml configuration path
The Drone settings screen from the original series, shown on a demo repository. The Protected setting is where signature verification was enabled.

By the end of July, we had a cluster we had tested by losing a node, a pipeline that could build and test our backend image, and a release path we could check back to a Git commit. The next step was to move the application fleet onto it.

Original series

The original series began on 3 March 2019 with the move from Rancher 1 to Kubernetes. The July installments cover the choice of Drone and the deployment pipeline.

  1. From the beginning to Rancher 1
  2. What was going wrong with Rancher 1
  3. Building the infrastructure for Rancher 2 and Kubernetes
  4. Choosing Drone for CI/CD
  5. Building the Drone pipeline