DEV Community

Cover image for Argo Rollouts: Unleashing Advanced Deployment Strategies
Pavan Belagatti
Pavan Belagatti

Posted on • Originally published at Medium

Argo Rollouts: Unleashing Advanced Deployment Strategies

In the fast-paced world of modern software development, Kubernetes has emerged as a leading container orchestration platform, empowering organizations to deploy and scale applications seamlessly. However, traditional deployment strategies often lack the finesse required to ensure smooth rollouts and minimize risks. Enter Argo Rollouts, an innovative solution that elevates Kubernetes deployments through progressive delivery techniques.

In this article, we will dive into the world of Argo Rollouts, through some practical examples of exploring how it revolutionizes the deployment process. I'll demonstrate how you can use Argo Rollouts to do Canary and Blue-Green deployments. Join us on this journey to uncover the secrets of Argo Rollouts and how it empowers developers to deliver applications with unprecedented confidence and efficiency.

Argo Rollouts

Argo Rollouts is a Kubernetes controller and toolset used for managing the progressive deployment of applications, particularly those hosted on Kubernetes clusters. It extends the functionality of Kubernetes Deployments and provides more advanced features for orchestrating the rollout of updates to applications.

Argo Rollouts Tutorial

Prerequisites:

  • Kubernetes cluster set up and kubectl installed and configured.

  • Argo CD and Argo Rollouts installed on your Kubernetes cluster.

kubectl create namespace argo-rollouts
Enter fullscreen mode Exit fullscreen mode
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml
Enter fullscreen mode Exit fullscreen mode
  • Argo Rollouts kubectl plugin. Install it with the following command
brew install argoproj/tap/kubectl-argo-rollouts
Enter fullscreen mode Exit fullscreen mode

Let's get started with the step-by-step tutorial:

Blue-Green Deployment Strategy

Let us demonstrate how to perform a blue-green deployment using Argo Rollouts on Kubernetes. Blue-green deployment is a deployment strategy where you have two identical environments, one is the current production environment (blue), and the other is the new environment you want to deploy (green). We will use Argo Rollouts to control the traffic switching between these environments.

Step 1: Deploy the Application
Create a simple Kubernetes deployment for your application. For this tutorial, we'll use a basic Nginx deployment:

# nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.19.10
        ports:
        - containerPort: 80
Enter fullscreen mode Exit fullscreen mode

Apply the deployment using kubectl:

kubectl apply -f nginx-deployment.yaml
Enter fullscreen mode Exit fullscreen mode

Step 2: Define the Argo Rollout Resource.
Create a Kubernetes manifest for the Argo Rollout resource:

# argo-rollout.yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: nginx-rollout
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  strategy:
    blueGreen:
      activeService: nginx-active
      previewService: nginx-preview
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.19.10
        ports:
        - containerPort: 80
Enter fullscreen mode Exit fullscreen mode

Step 3: Create Services.
Now, create two services: one for the current production environment (blue) and the other for the new environment (green).

# nginx-active-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: nginx-active
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
Enter fullscreen mode Exit fullscreen mode
# nginx-preview-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: nginx-preview
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
Enter fullscreen mode Exit fullscreen mode

Apply the services:

kubectl apply -f nginx-active-service.yaml
kubectl apply -f nginx-preview-service.yaml
Enter fullscreen mode Exit fullscreen mode

Step 4: Apply the Argo Rollout

kubectl apply -f argo-rollout.yaml
Enter fullscreen mode Exit fullscreen mode

Step 5: Monitor the Deployment
You can monitor the status of the deployment using:

kubectl argo rollouts get rollout nginx-rollout
Enter fullscreen mode Exit fullscreen mode

You should see a screen as shown below,
nginx deploy

Step 6: Perform the Blue-Green Switch:
To switch traffic from the blue to the green environment, update the Argo Rollout resource with a new image or configuration. Argo Rollouts will handle the gradual switch.
For example, update the nginx image in the argo-rollout.yaml file to a new version, and then apply the update:

kubectl apply -f argo-rollout.yaml
Enter fullscreen mode Exit fullscreen mode

Checking the initial rollout with the UI (use the below command)

kubectl argo rollouts dashboard -n blue-green
Enter fullscreen mode Exit fullscreen mode

The below Blue-Green deployment is what you see in the UI.
nginx bluegreen

If you click on this Blue-Green deployment, you will see the detailed image.
bluegreen rollout bg

Canary Deployment Strategy

Deploying a Rollout:

First, we deploy a Rollout resource and a Kubernetes Service targeting that Rollout.

The example Rollout in this guide utilizes a canary update strategy which sends 20% of traffic to the canary, followed by a manual promotion, and finally gradual automated traffic increases for the remainder of the upgrade. This behavior is described in the following portion of the Rollout spec:

rollout description

You can find the spec link here: https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/basic/rollout.yaml
Run the following command to deploy the initial Rollout and Service:

kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/basic/rollout.yaml
Enter fullscreen mode Exit fullscreen mode
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-rollouts/master/docs/getting-started/basic/service.yaml
Enter fullscreen mode Exit fullscreen mode

To watch the rollout as it deploys, run the get rollout --watch command from plugin:

kubectl argo rollouts get rollout rollouts-demo --watch

Enter fullscreen mode Exit fullscreen mode

canary healthy

Let's check the UI with the below command

kubectl argo rollouts dashboard
Enter fullscreen mode Exit fullscreen mode

canary strategy deployment

This way, you can perform the advanced deployment strategies using Argo Rollouts.

Overall, Argo Rollouts offers a more powerful and controlled approach to deploying updates to Kubernetes-based applications, allowing you to mitigate risks and ensure the stability and reliability of your production environment during the deployment process. Now you can trigger your Argo CD jobs and workflows automatically from Kubiya, a virtual assistant for DevOps professionals.

Follow me on Twitter to get daily updates on interesting tech articles and stories.

Top comments (4)

Collapse
 
mxglt profile image
Maxime Guilbert

Nice post! :)

Collapse
 
pavanbelagatti profile image
Pavan Belagatti

Thanks!

Collapse
 
adriens profile image
adriens

Very nice post, we are also curretnly deploying argoCD... I've bookmarked your post and will share it to the team.
Thanks a lot for the detailed post.

Collapse
 
pavanbelagatti profile image
Pavan Belagatti

Thanks for the comment.