Getting Started with Argo Rollouts for Canary Deployments in Kubernetes

In the ever-evolving landscape of cloud-native technologies, automating the deployment, scaling, and management of applications is crucial for efficiency and agility. One such technology that has gained significant traction is Argo Rollouts. Argo Rollouts is a Kubernetes controller and set of CRDs (Custom Resource Definitions) that provide advanced deployment capabilities, including Blue-Green Deployments, Canary Releases, and Progressive Delivery. In this blog post, we will explore how to get started with Argo Rollouts, focusing on implementing a canary deployment strategy.

Why Argo Rollouts?

Argo Rollouts offers several compelling features:

  • Advanced Deployments: Supports various deployment strategies such as Blue-Green, Canary, and Progressive Delivery.
  • Observability: Provides detailed metrics and analysis for better observability during deployments.
  • Integration: Integrates with popular tools like Prometheus, Datadog, and Slack for notifications and monitoring.
  • GitOps Friendly: Works well with GitOps workflows, increasing transparency and traceability in the deployment process.

Getting Started with Argo Rollouts

Step 1: Install Argo Rollouts

The first step is to install the Argo Rollouts controller in your Kubernetes cluster. You can do this using the following command:

kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml

This will install the necessary CRDs and start the Argo Rollouts controller in the argo-rollouts namespace.

Step 2: Create a Canary Deployment

Next, let’s create a canary deployment for a sample application. Here is a YAML configuration for a canary rollout:

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: sample-rollout
  namespace: default
spec:
  replicas: 3
  strategy:
    canary:
      steps:
        - setWeight: 20
        - pause: {}
        - setWeight: 40
        - pause: {duration: 20s}
        - setWeight: 60
        - pause: {}
  selector:
    matchLabels:
      app: sample-app
  template:
    metadata:
      labels:
        app: sample-app
    spec:
      containers:
      - name: sample-app
        image: nginx:latest
        ports:
        - containerPort: 80

This configuration creates a canary deployment with incremental traffic weights. It starts at 20% and gradually increases to 60%, with pauses allowing you to monitor the deployment at each step.

Step 3: Apply the Rollout

Apply the rollout configuration using kubectl:

kubectl apply -f sample-rollout.yaml

This will create a new Rollout resource in your Kubernetes cluster. You can monitor the status of the rollout using:

kubectl argo rollouts get rollout sample-rollout

Observing the Rollout

Argo Rollouts comes with a set of commands to observe and manage the rollout process. For instance, you can watch the progress of the rollout using:

kubectl argo rollouts get rollout sample-rollout --watch

This provides a real-time view of each step in the canary deployment process.

Metrics and Analysis

Integrate Argo Rollouts with monitoring tools like Prometheus to gather metrics during the deployment. Here’s an example configuration for a Prometheus alert:

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: sample-rollout-alert
  namespace: default
spec:
  groups:
  - name: sample-rollout-rules
    rules:
    - alert: SampleRolloutFailure
      expr: rate(rollout_status_fails[5m]) > 0
      for: 1m
      labels:
        severity: critical
      annotations:
        summary: "Sample Rollout Failure"
        description: "The sample rollout has encountered a failure."

Deploy this rule to Prometheus to get alerted on any failures immediately, allowing you to take swift action.

Lessons Learned: A Real-World Story

One of our clients, a leading e-commerce platform, implemented Argo Rollouts for their microservices. Initially, they faced challenges with their traditional deployment methods, which often led to downtime and user dissatisfaction. By transitioning to Argo Rollouts and leveraging canary deployments, they significantly reduced deployment risks. They were able to catch and mitigate issues early by monitoring incremental traffic shifts, leading to a more stable application and improved user experience.

Conclusion

Argo Rollouts is a powerful tool for managing complex deployments in cloud-native environments. It provides advanced deployment strategies, detailed observability, and easy integration with other tools. By following the steps outlined in this post, you can get started with Argo Rollouts and implement effective deployment strategies like canary releases. This approach can help minimize risks, ensure stable releases, and ultimately lead to a more reliable and resilient application architecture.

Are you using Argo Rollouts in your deployments? Share your experiences and best practices in the comments below!