Progressive Delivery with Argo Rollouts : Blue-Green Deployment

Progressive Delivery with Argo Rollouts : Blue-Green Deployment

Ninad Desai
Ninad Desai

To understand about blue-green deployment with Argo Rollouts

Continuous Integration (CI) and Continuous Delivery (CD) have been widely adopted in modern software development enabling organizations to quickly deploy these software to customers. But doing it in the right way is equally important as in some cases unfinished code can lead to failures and customers have to face downtime. So to solve this, progressive delivery was introduced which enables the delivery of software with the right changes to the right amount of customers at the right time. More precisely, it controls the speed at which changes are deployed for a software.

Traditional CI/CD and Progressive Delivery

Continuous Integration (CI) is an automation process that helps in continuously integrating software development changes. It automates the building, testing, and validation of the source code. Its goal is to ultimately produce a packaged artifact that is ready to deploy.

Continuous Delivery (CD) helps in deploying software changes to users. It needs CI which produces an artifact that can be deployed to users. Hence, CI and CD are often used together.

But Continuous Delivery poses many challenges, such as handling fast delivery of changes, handling high-risk failures, to ensure uptime and efficient performance of the software. To solve the above problems of continuous delivery, progressive delivery comes into action along with different deployment strategies like blue-green deployment, canary deployment.

Progressive Delivery is one step ahead of Continuous Delivery. It enables delivering the software updates in a controlled manner by reducing the risks of failures. It is done by exposing the new changes of software to a smaller set of users, and then by observing and analyzing the correct behavior, it is then exposed to more users progressively. It is known to move fast but with control.

Challenges with default “RollingUpdate” Kubernetes deployment strategy

Kubernetes comes up with default RollingUpdate deployment strategy which at present, have below set of limitations:

  • Fewer controls over speed of the rollout
  • Inability to control traffic flow to the new version
  • Readiness probes are unsuitable for deeper, stress, or one-time checks
  • No ability to query external metrics to verify an update
  • Can halt the progression, but unable to automatically abort and rollback the update

Argo Projects

Argo is a group of many open source projects which help in the fast and safe delivery of software by extending the capabilities of Kubernetes.

  • Argo Workflows - Container-native Workflow Engine
  • Argo CD - Declarative GitOps Continuous Delivery
  • Argo Events - Event-based Dependency Manager
  • Argo Rollouts - Progressive Delivery with support for Canary and Blue Green deployment strategies
  • Argoproj-labs - separate GitHub org that is setup for community contributions related to the Argoproj ecosystem

To overcome the limitations of native Kubernetes deployment strategies, Argo Rollouts has been introduced and it contains below a different set of projects.

What is Argo Rollouts?

Argo Rollouts is a Kubernetes controller and a set of CRDs which provides progressive delivery features along with advanced deployments such as blue-green, canary, canary analysis. It has the potential to control and shift traffic to a newer version of software through ingress controllers and service meshes.

The below table shows comparative analysis of capabilities of the default Kubernetes deployment strategy vs ArgoRollouts.

Argo Rollouts

Working of Argo Rollouts

Argo Rollout controller helps in finding and detecting the resource of a kind: Rollout in the cluster which manages the replicasets just like Kubernetes Deployment does. It creates a stable replicaset for the older version of the software and a canary replicaset for the newer version of the software.

Working of Argo Rollouts

source: Argo-Rollout-Architecture

The AnalysisTemplate helps in doing the analysis of the replicasets through the AnalysisRun component. Together, they help to observe the working of the newly deployed version. Accordingly, it can automatically roll out to a newer version or roll back it. For this one can use any metrics tool like Prometheus, Kubernetes jobs, and so on.

Lab/Hands-on of Argo Rollouts with Blue-Green Deployments

If you do not have k8s cluster readily available to do further lab then we recommend to go for CloudYuga platform based version of this blogpost. Else, you can set up your own kind local cluster with nginx controller also deployed,and follow along to execute below commands against your kind cluster.

Clone the Argo Rollouts example GitHub repo or preferably, please fork this

git clone https://github.com/NiniiGit/argo-rollouts-example.git

Installation of Argo Rollouts controller

  • Create the namespace for installation of the Argo Rollouts controller
kubectl create namespace argo-rollouts

You will see the namespace has been created

kubectl get ns argo-rollouts

We will use the latest version to install the Argo Rollouts controller.

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

You will see the controller and other components have been deployed. Wait for the pods to be in the Running state.

kubectl get all -n argo-rollouts

Install Argo Rollouts Kubectl plugin with curl for easy interaction with Rollout controller and resources.

curl -LO https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64
chmod +x ./kubectl-argo-rollouts-linux-amd64
sudo mv ./kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts
kubectl argo rollouts version

Argo Rollouts comes with its own GUI as well that you can access with the below command

kubectl argo rollouts dashboard

and now you can access Argo Rollout console, by accessing http://localhost:3100 on your browser. You would be presented with UI as shown below (currently it won’t show you anything since we are yet to deploy any Argo Rollouts based app)

Argo Rollouts Dashboard

Now, let’s go ahead and deploy our first sample app using the Blue-Green Deployment strategy.

Blue-Green Deployment with Argo Rollouts

To experience how the blue-green deployment works with Argo Rollouts, we will deploy the sample app which contains Rollouts, Service, and Ingress as Kubernetes objects.
rollout.yaml content:

# This example demonstrates a Rollout using the blue-green update strategy, which contains a manual
# gate before promoting the new stack.
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: rollout-bluegreen
spec:
  replicas: 2
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: rollout-bluegreen
  template:
    metadata:
      labels:
        app: rollout-bluegreen
    spec:
      containers:
      - name: rollouts-demo
        image: argoproj/rollouts-demo:blue
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
  strategy:
    blueGreen:
      # activeService specifies the service to update with the new template hash at time of promotion.
      # This field is mandatory for the blueGreen update strategy.
      activeService: rollout-bluegreen-active
      # previewService specifies the service to update with the new template hash before promotion.
      # This allows the preview stack to be reachable without serving production traffic.
      # This field is optional.
      previewService: rollout-bluegreen-preview
      # autoPromotionEnabled disables automated promotion of the new stack by pausing the rollout
      # immediately before the promotion. If omitted, the default behavior is to promote the new
      # stack as soon as the ReplicaSet are completely ready/available.
      # Rollouts can be resumed using: `kubectl argo rollouts promote ROLLOUT`
      autoPromotionEnabled: false

service.yaml content:

kind: Service
apiVersion: v1
metadata:
  name: rollout-bluegreen-active
spec:
  selector:
    app: rollout-bluegreen
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080

---
kind: Service
apiVersion: v1
metadata:
  name: rollout-bluegreen-preview
spec:
  selector:
    app: rollout-bluegreen
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080

ingress.yaml content:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: rollout-bluegreen
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: rollout-bluegreen-active
            port:
              number: 80

Now, let’s create all these objects for now in the default namespace. Please execute the below commands:

kubectl apply -f argo-rollouts-example/blue-green-deployment-example/

You would be able to see all the objects been created in the default namespace by running the below commands:

kubectl get all

Now, you can access your sample app, by accessing http://localhost:80 on your browser.
You would be able to see the app as shown below:

Argo Rollouts sample app with blue-version

Now, again visit the Argo-Rollouts console. And this time, you could see the sample deployed on the Argo Rollouts console as below:

Blue-Green deployment on argo rollouts dashboard

You can click on this rollout-bluegreen in the console and it will present you with its current status as below:

Details of blue-green deployment

Going forward, either you can use this GUI or else (Preferably) use the commands shown below to continue with this demo.

You can see the current status of this rollout by running the below command as well

kubectl argo rollouts get rollout rollout-bluegreen

Now, let’s deploy the Green version of the app via command line

kubectl argo rollouts set image rollout-bluegreen rollouts-demo=argoproj/rollouts-demo:green

​​You would be able to see new i.e green version based set of pods of our sample app, coming up

kubectl get pods

Now, after a few seconds, you would be able to see both your old set of pods (with version blue) as well as the new set of pods(with version green) available. Also on the Argo console, you would be able to see below the kind of new revision of the app with the changed image version running.

New Version of blue-green deployement

If you visit the http://localhost:80 on your browser, you would still see only the blue version is visible rightly because we have not yet fully promoted the green version of our app You can confirm the same now, by running the command below, which shows the new version is in paused state.

kubectl argo rollouts get rollout rollout-bluegreen
  • Now, let us promote the green version of our app, by executing below command
kubectl argo rollouts promote rollout-bluegreen

Run the following command and you would see it’s scaling the new i.e green version of our app completely.

kubectl argo rollouts get rollout rollout-bluegreen

The same can be confirmed by running the below command, which shows the old set of pods i.e old blue version of our app, terminating or already terminated.

kubectl get pods

If you visit the app URL on http://localhost:80 on your browser, you would see only the Green version is visible right now because we have fully promoted the green version of our app

Argo Rollouts sample app with green-version

Congratulations!! you have successfully completed the blue-green deployment using Argo Rollouts.

  • You can delete this entire setup i.e our sample deployed app using the below command.
kubectl delete -f argo-rollouts-example/blue-green-deployment-example/

Summary

In this post, we discussed what progressive delivery is all about and its characteristics. We also learned about ArgoRollouts custom controller and how it can help to achieve the blue-green deployment, which is ultimately a form of progressive delivery.

I hope you found this post informative and engaging. For more posts like this one, do subscribe to our weekly newsletter. I’d love to hear your thoughts on this post, so start a conversation on Twitter or LinkedIn :)

What Next? Now we have developed an understanding of progressive delivery and created a blue-green deployment. Next would be to try the canary deployment using Argo Rollouts.

You can find all the parts of this Argo Rollouts Series below:

References and further reading:

Argo Rollouts
Argo Rollouts - Kubernetes Progressive Delivery Controller
How to Setup Blue Green Deployments with DNS Routing InfraCloud’s Progressive Delivery Consulting services

Looking for Progressive Delivery consulting and support? Explore how we’re helping companies adopt progressive delivery - from creating a roadmap to successful implementation, & enterprise support.

Infracloud logo

Adopt DevOps Faster with InfraCloud's Expertise

Consult DevOps Experts

Posts You Might Like

This website uses cookies to offer you a better browsing experience