Chapter 20

The Autopilot: CI/CD for a Global Network

Subhash Choudhary · 10 min read

We had reached a state of operational nirvana. Our global, self-hosted, bare-metal Kubernetes infrastructure was fast, resilient, and cheap. Our observability platform gave us unprecedented insight into every corner of our complex system. We had built a Formula 1 car, and we had the live telemetry to prove it.

But there was one part of our process that was still painfully manual, slow, and human. The process of actually getting a new version of our software from a developer's laptop and onto our global fleet of nine Kubernetes clusters.

The very thing that made our system so resilient-its distributed, multi-regional nature-also made it a nightmare to update. This chapter is about building the final piece of our modern infrastructure: a fully automated, global deployment pipeline that could act as the autopilot for our entire system.

Part 1: The Pain of Nine Deployments

A new version of our storefront-service was ready. It had a bug fix and a small performance improvement. In the old days, deploying this would have been a single command. Now, it was a high-stakes, hour-long ceremony that I had to perform myself.

My terminal window would be open, and I would begin the manual, region-by-region rollout.

The process was horribly inefficient and fraught with risk.

The breaking point came during a routine deployment. I accidentally applied a configuration meant for the storefront to our api-service in the Singapore cluster. It caused a brief but real outage for all our users in Southeast Asia. We fixed it in ten minutes, but the damage was done.

Suumit saw the dip in the sales charts. "What happened in Singapore?" he asked. I explained the human error. "We can't operate like this," he said. "The process needs to be foolproof. It needs to be automated."

Identifying the Problem: A Manual and Error-Prone Process

We had a state-of-the-art, self-healing production environment. But our process for changing that environment was a fragile, manual relic of our past. It wasn't scalable, it wasn't reliable, and it created a key-person dependency on whoever was brave enough to run the deployment.

We needed a system that treated our nine clusters as a single, logical unit. We needed a pipeline that could take a developer's approved code and automatically, consistently, and safely deliver it to our entire global fleet without a human having to touch a single server. We needed a true CI/CD pipeline.

Part 2: The Assembly Line and the Delivery Truck (CI/CD)

To solve our painful deployment problem, we needed to build a true assembly line for our code. The industry term for this is CI/CD, and it represents a philosophy that would completely transform how we ship software.

Technical Deep Dive: What is CI/CD?

CI/CD stands for Continuous Integration and Continuous Deployment (or Delivery). It sounds complex, but it's two simple ideas working together.

CI: Continuous Integration (The Quality Control Station)

Continuous Integration is the practice of developers frequently merging their code changes into a central repository. After each merge, an automated process kicks off to build and test the application.

CD: Continuous Deployment (The Automated Delivery Fleet)

Continuous Deployment takes the output of a successful CI process and automatically deploys it to production.


#### **Our CI Pipeline: GitHub Actions**

For the first part of our pipeline, Continuous Integration, we used a tool called GitHub Actions. Since all our code was already hosted on GitHub, this was a natural choice. It allowed us to define our automation workflows in a simple YAML file right alongside our code.

We configured a GitHub Actions workflow that would automatically trigger every time a developer opened a Pull Request. This was our new, automated quality control station.

The output of our CI pipeline was a single, immutable, production-ready artifact: a Docker image. We now had an automated and completely reliable process for building our "shipping containers." The CI half of the equation was solved.

We had perfected our factory for building high-quality cars and stocking them in the warehouse. Now we needed to build the fully autonomous, global delivery truck fleet. We needed to solve the Continuous Deployment problem.

Part 3: The Autopilot (GitOps with Argo CD)

Our CI pipeline with GitHub Actions was a masterpiece of automation. It took a developer's raw code and reliably produced a single, tested, and trusted artifact: a new Docker image, safely stored in our container registry. We had perfected the factory that built our high-quality cars.

But the cars were still sitting in the warehouse. We still faced the problem of how to deliver this new image (dukaan/storefront:v2.3.1) to our nine global Kubernetes clusters. The old, imperative way would be to write a script that runs a kubectl set image... command nine times. This is still a manual push, and it's still risky.

We needed a more elegant, reliable, and automated approach. We found it in a powerful philosophy called GitOps.

Technical Deep Dive: What is GitOps?

GitOps is a revolutionary way to think about Continuous Deployment for cloud-native applications. The core idea is simple but profound: a Git repository is the single source of truth for the desired state of your entire production environment.

To make a change to your infrastructure, you don't SSH into a server or run kubectl commands from your laptop. You change a configuration file in a Git repository, open a Pull Request, and get it reviewed and merged. An automated agent then ensures that your live environment matches the state described in the Git repository.

This process is pull-based, auditable, and incredibly safe.

Our Tool: Argo CD

The "librarian" we chose for our system was an open-source GitOps tool called Argo CD.

Argo CD is a controller that runs inside your Kubernetes clusters. Its only job is to continuously monitor a Git repository and compare the state defined there with the actual state running in the cluster. If it detects a difference, it automatically takes action to sync the two, ensuring the cluster always mirrors the source of truth in Git.

Here's how we implemented our new, fully automated deployment pipeline:

The New Deployment Workflow: A Merged PR

With this system in place, our deployment process became a thing of beauty, simplicity, and safety.

This happens in parallel, automatically, across our entire global fleet. We had built a true autopilot. The hour-long, stressful, manual deployment ceremony was now a calm, five-second, auditable Git merge.

Key Takeaways

  • CI/CD is the foundation of modern, agile software delivery. Continuous Integration (CI) ensures your code is always in a healthy state, while Continuous Deployment (CD) ensures you can deliver it to users safely and quickly.
  • A CI pipeline is your automated quality gate. It should automatically test your code, lint it for style, and produce a single, immutable artifact (like a Docker image) as its output.
  • GitOps is the superior, declarative model for Continuous Deployment. By using a Git repository as the single source of truth for your infrastructure's state, you make your deployments safer, more transparent, and fully auditable.
  • Tools like Argo CD act as the automated agent for GitOps. They continuously reconcile the state of your live cluster with the desired state defined in your Git repository.
  • We had finally mastered the process of changing our complex machine. Deployments were no longer a source of fear, but a routine, boring, and safe non-event.