Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Blue/green deployment strategy with Argo Rollouts

January 29, 2024
David Severiano
Related topics:
CI/CDGitOpsKubernetes
Related products:
Red Hat OpenShift

Share:

    A critical topic in cloud-native applications is the deployment strategy. We are no longer dealing with one monolithic application. We have several applications that have dependencies on each other and also have other dependencies like brokers or databases.

    Applications have their own life cycle, so we should be able to execute independent blue/green deployment. All the applications and dependencies will not change their version at the same time.

    Another important topic in the cloud-native space is continuous delivery. If we are going to have several applications doing blue/green deployment independently, we have to automate it. We will use Helm, Argo Rollouts, Red Hat OpenShift GitOps, and, of course, Red Hat OpenShift to help us.

    Argo Rollouts is a Kubernetes controller and set of Custom Resource Definitions (CRDs) that provide advanced deployment capabilities such as blue-green, canary, canary analysis, experimentation, and progressive delivery features to Kubernetes. In this demo, we are going to use blue-green capabilities.

    In the next steps, we will see a real example of how to install, deploy, and manage the life cycle of cloud-native applications doing blue/green deployment using Argo Rollouts.

    If you want to know more about blue/green deployment, read Blue/green deployment strategy with OpenShift Pipelines.

    Let's start with some theory; after that, we will have a hands-on example.

    Shop application

    We are going to use very simple applications to test blue/green deployment. We have created two Quarkus applications, Products and Discounts. Figure 1 shows the Shop applications.

    Shop
    Figure 1: Shop
    Figure 1: The example Shop applications.

    Products call Discounts to get the product's discount and expose an API with a list of products with its discounts.

    Shop blue/green

    To achieve blue/green deployment with cloud-native applications using Argo Rollouts, we have designed this architecture, which you can see in Figure 2.

    Shop Blue/Green
    Figure 2: Shop Blue/Green
    Figure 2: Shop Blue/Green.

    OpenShift Components - Online:

    • Routes and Services declared with the suffix -online
    • Routes mapped only to the online services
    • Services mapped to the rollout.

    OpenShift Components - Offline:

    • Routes and Services declared with the suffix -offline
    • Routes mapped only to the offline services
    • Services mapped to the rollout

    This is an example of products rollout manifest:

      strategy:
        blueGreen:
          activeService: products-umbrella-online
          previewService: products-umbrella-offline      
          autoPromotionEnabled: false
          prePromotionAnalysis:
            templates:
              - templateName: products-analysis-template
    

    We have defined an active or online service, products-umbrella-online, and a preview or offline service products-umbrella-offline. Final user will always use products-umbrella-online. We have created an AnalysisTemplate, products-analysis-template, that just validates the health of the application, for production environments a better analysis should be done. Argo Rollouts use this AnalysisTemplate to validate a new version and set it ready to be promoted or not. To learn more, read BlueGreen Deployment Strategy.

    Shop Umbrella Helm chart

    One of the best ways to package Cloud Native applications is Helm. In blue/green deployment it makes even more sense. We have created a chart for each application that knows nothing about blue/green. Then we pack everything together in an umbrella helm chart that you can see in Figure 3.

    Shop Umbrella Helm Chart
    Figure 3: Shop Umbrella Helm Chart
    Figure 3: A diagram of the shop umbrella Helm Chart.

    In the Shop Umbrella Chart we use several times the same charts as helm dependencies but with different names if they are online/offline. This will allow us to have different configurations for each color.

    We have packaged both applications in one chart, but we may have different umbrella charts per application.

    Demo

    Prerequisites:

    • Red Hat OpenShift 4.13 with admin rights.
      • Download Red Hat OpenShift Local for OCP 4.13.
      • Getting Started Guide
    • Git
    • GitHub account
    • oc 4.13 command-line interface (CLI)
    • Argo Rollouts CLI

    We have a GitHub repository for this demo. As part of the demo, you will have to make some changes and commits. So it is important that you fork the repository and clone it in your local:

    git clone https://github.com/your_user/cloud-native-deployment-strategies

    If we want to have a cloud-native deployment, we cannot forget CI/CD. Red Hat OpenShift GitOps will help us.

    Install OpenShift GitOps

    Go to the folder where you have cloned your forked repository and create a new branch called rollouts.

    git checkout -b rollouts
    git push origin rollouts
    

    Log in to OpenShift as a cluster admin and install the OpenShift GitOps operator with the following command. This might take a few minutes.

    oc apply -f gitops/gitops-operator.yaml
    

    Once OpenShift GitOps is installed, an instance of Argo CD is automatically installed on the cluster in the openshift-gitops namespace and a link to this instance is added to the application launcher in OpenShift Web Console.

    Log in to the Argo CD dashboard

    Argo CD upon installation generates an initial admin password which is stored in a Kubernetes secret. In order to retrieve this password, run the following command to decrypt the admin password:

    oc extract secret/openshift-gitops-cluster -n openshift-gitops --to=-
    

    Click on Argo CD from the OpenShift Web Console application launcher and then log into Argo CD with admin username and the password retrieved from the previous step.

    Configure OpenShift with Argo CD

    We are going to follow, as much as we can, a GitOps methodology in this demo. So we will have everything in our Git repository and use Argo CD to deploy it in the cluster.

    In the current Git repository, the gitops/cluster-config directory contains OpenShift cluster configurations such as:

    • namespaces gitops.
    • role binding for Argo CD to the namespace gitops.
    • namespaces argo-rollouts.

    • Argo Rollouts RolloutManager.

    Let's configure Argo CD to recursively sync the content of the gitops/cluster-config directory into the OpenShift cluster.

    Execute this command to add a new Argo CD application that syncs a Git repository containing cluster configurations with the OpenShift cluster.

    oc apply -f blue-green-argo-rollouts/application-cluster-config.yaml
    

    Looking at the Argo CD dashboard, you will notice that an application has been created.

    You can click on the cluster-configuration application to check the details of sync resources and their status on the cluster.

    Create Shop application

    We are going to create the application shop, that we will use to test blue/green deployment. Because we will make changes in the application's GitHub repository, we have to use the repository that you have just forked. Edit the file blue-green-argo-rollouts/application-shop-blue-green-rollouts.yaml and set your own GitHub repository in the reportURL.

    apiVersion: argoproj.io/v1alpha1
    kind: Application
    metadata:
      name: shop
      namespace: openshift-gitops
    spec:
      destination:
        name: ''
        namespace: gitops
        server: 'https://kubernetes.default.svc'
      source:
        path: helm/quarkus-helm-umbrella/chart
        repoURL:  https://github.com/change_me/cloud-native-deployment-strategies.git
        targetRevision: rollouts
        helm:
          parameters:
          - name: "global.namespace"
            value: gitops
          valueFiles:
            - values/values-rollouts-blue-green.yaml
      project: default
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
    
    oc apply -f blue-green-argo-rollouts/application-shop-blue-green-rollouts.yaml
    

    Looking at the Argo CD dashboard, you will notice that we have a new shop application, as shown in Figure 4.

    ArgoCD Applications
    Figure 4: ArgoCD Applications
    Figure 4: Argo CD applications.

    Test Shop application

    We have deployed the shop with Argo CD. We can test that it is up and running.

    We have to get the Online route:

    curl -k "$(oc get routes products-umbrella-online -n gitops --template='https://{{.spec.host}}')/products"
    

    And the Offline route:

    curl -k "$(oc get routes products-umbrella-offline -n gitops --template='https://{{.spec.host}}')/products"
    

    Notice that in each microservice response, we have added metadata information to see better the version of each application. This will help us to see the changes while we do the blue/green deployment. Because right now we have both routers against the same rollout revision we will have the same response with the version v1.0.1:

    {
       "products":[
          {
             ...
             "name":"TV 4K",
             "price":"1500€"
          }
       ],
       "metadata":{
          "version":"v1.0.1", <--
          "colour":"none",
          "mode":"online"
       }
    }
    

    We can also see the rollout's status. Argo Rollouts offers a kubectl plug-in to enrich the experience with Rollouts.

    kubectl argo rollouts get rollout products --watch -n gitops
    
    NAME                                  KIND        STATUS     AGE INFO
    ⟳ products                            Rollout     ✔ Healthy  12m  
    └──# revision:1                                                   
       └──⧉ products-67fc9fb79b           ReplicaSet  ✔ Healthy  12m  stable,active
          ├──□ products-67fc9fb79b-49k25  Pod         ✔ Running  12m  ready:1/1
          └──□ products-67fc9fb79b-p7jk9  Pod         ✔ Running  12m  ready:1/1
    

    Products blue/green deployment

    We have split a Cloud Native blue/green deployment into two steps:

    1. Deploy a new version.
    2. Promote a new version.

    We have already deployed the products v1.0.1, and we are ready to use a new products v1.1.1 that has a new description attribute.

    Figure 5 has the current status.

    Step 0
    Figure 5: Step 0
    Figure 5: Step 0.

    Step 1: Deploy a new version

    We will deploy a new version, v1.1.1. To do it, we have to edit the file helm/quarkus-helm-umbrella/chart/values/values-rollouts-blue-green.yaml under products-blue set tag value to v.1.1.1.

    products-blue:
      mode: online
      image:
        tag: v1.1.1
    

    And push the changes:

    git add .
    git commit -m "Change products version to v1.1.1"
    git push origin rollouts
    

    Argo CD will refresh the status after some minutes. If you don't want to wait you can refresh it manually from Argo CD UI or configure the Argo CD Git webhook.

    Argo Rollouts will automatically deploy the new products version and execute the prePromotionAnalysis.

    NAME                                  KIND         STATUS        AGE  INFO
    ⟳ products                            Rollout      ॥ Paused      27m  
    ├──# revision:2                                                       
    │  ├──⧉ products-9dc6f576f            ReplicaSet   ✔ Healthy     36s  preview
    │  │  ├──□ products-9dc6f576f-6vqp5   Pod          ✔ Running     36s  ready:1/1
    │  │  └──□ products-9dc6f576f-lmgd7   Pod          ✔ Running     36s  ready:1/1
    │  └──α products-9dc6f576f-2-pre      AnalysisRun  ✔ Successful  31s  ✔ 1
    └──# revision:1                                                       
       └──⧉ products-67fc9fb79b           ReplicaSet   ✔ Healthy     27m  stable,active
          ├──□ products-67fc9fb79b-49k25  Pod          ✔ Running     27m  ready:1/1
          └──□ products-67fc9fb79b-p7jk9  Pod          ✔ Running     27m  ready:1/1
    

    If the prePromotionAnalysis goes well, we can see that offline applications have version v1.1.1 and the new attribute description, but the online version has not changed.

    Figure 6 has the current status.

    Step 1
    Figure 6: Step 1
    Figure 6: Step 1.
    {
      "products":[
         {
            "discountInfo":{...},
            "name":"TV 4K",
            "price":"1500€",
            "description":"The best TV" <--
         }
      ],
      "metadata":{
         "version":"v1.1.1", <--
      }
    }
    

    Functional testing users can execute Smoke tests to validate this new v1.1.1 version.

    Step 2: Promote a new version

    We are going to open the new version to final users.

    Execute this command to promote products:

    kubectl argo rollouts promote products -n gitops
    

    First, Argo Rollouts will just change the service to use the new release (ReplicaSet). We minimize downtime because it just changes the service label.

    NAME                                  KIND         STATUS        AGE  INFO
    ⟳ products                            Rollout      ✔ Healthy     88m  
    ├──# revision:2                                                       
    │  ├──⧉ products-9dc6f576f            ReplicaSet   ✔ Healthy     62m  stable,active
    │  │  ├──□ products-9dc6f576f-6vqp5   Pod          ✔ Running     62m  ready:1/1
    │  │  └──□ products-9dc6f576f-lmgd7   Pod          ✔ Running     62m  ready:1/1
    │  └──α products-9dc6f576f-2-pre      AnalysisRun  ✔ Successful  62m  ✔ 1
    └──# revision:1                                                       
       └──⧉ products-67fc9fb79b           ReplicaSet   ✔ Healthy     88m  delay:27s
          ├──□ products-67fc9fb79b-49k25  Pod          ✔ Running     88m  ready:1/1
          └──□ products-67fc9fb79b-p7jk9  Pod          ✔ Running     88m  ready:1/1
    

    Figure 7 has the current status.

    Step 2 initial
    Figure 7: Step 2 initial
    Figure 7: Step 2 initial.

    And after scaleDownDelaySeconds, Argo Rollouts will scale down the first replicaSet (v1.0.1).

     NAME                                 KIND         STATUS        AGE  INFO
    ⟳ products                           Rollout      ✔ Healthy     89m  
    ├──# revision:2                                                      
    │  ├──⧉ products-9dc6f576f           ReplicaSet   ✔ Healthy     62m  stable,active
    │  │  ├──□ products-9dc6f576f-6vqp5  Pod          ✔ Running     62m  ready:1/1
    │  │  └──□ products-9dc6f576f-lmgd7  Pod          ✔ Running     62m  ready:1/1
    │  └──α products-9dc6f576f-2-pre     AnalysisRun  ✔ Successful  62m  ✔ 1
    └──# revision:1                                                      
       └──⧉ products-67fc9fb79b          ReplicaSet   • ScaledDown  89m
    

    Figure 8 has the current status.

    Step 2
    Figure 8: Step 2
    Figure 8: Step 2.

    We have in the online environment the new version v1.1.1!

    {
      "products":[
         {
            "discountInfo":{...},
            "name":"TV 4K",
            "price":"1500€",
            "description":"The best TV" <--
         }
      ],
      "metadata":{
         "version":"v1.1.1", <--
      }
    }
    

    Rollback

    Imagine that something goes wrong—we know that this never happens, but just in case. We can do a very quick rollback just undoing the change in the Products online service.

    Argo Rollouts has an undo command to do the rollback. Personally, I don't like this procedure because it is not aligned with GitOps. The changes that Argo Rollouts do does not come from Git, so Git is OutOfSync with what we have in OpenShift. In our case the commit that we have done not only changes the ReplicaSet but also the ConfigMap. The undo command only changes the ReplicaSet, so it does not work for us.

    I recommend doing the changes in Git. We will revert the last commit:

    git revert HEAD
    git push origin rollouts
    

    Argo CD will get the changes and apply them. Argo Rollouts will create a new revision with the previous version, Figure 9 has the Shop status.

    Rollback init
    Figure 9: Rollback init
    Figure 9: Rollback init.

    Execute this command to promote products to version v1.0.1:

    kubectl argo rollouts promote products -n gitops
    

    As you can see in Figure 10, the rollback is done!

    Rollback
    Figure 10: Rollback
    Figure 10: Rollback.
    {
       "products":[
          {
             ...
             "name":"TV 4K",
             "price":"1500€"
          }
       ],
       "metadata":{
          "version":"v1.0.1", <--
          "colour":"none",
          "mode":"online"
       }
    }
    

    Delete environment

    To delete all the things that we have done for the demo you have to:

    • In GitHub, delete the branch rollouts.
    • In Argo CD, delete the application cluster-configuration and shop.
    • In OpenShift, go to project openshift-operators and delete the installed operators Openshift GitOps.

    Related Posts

    • Blue/green deployment strategy with OpenShift Pipelines

    • 3 patterns for deploying Helm charts with Argo CD

    • Multiple sources for Argo CD applications

    • Automate CI/CD on pull requests with Argo CD ApplicationSets

    • Introduction to Tekton and Argo CD for multicluster development

    • How to set up your GitOps directory structure

    Recent Posts

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    • How to debug confidential containers securely

    • Announcing self-service access to Red Hat Enterprise Linux for Business Developers

    What’s up next?

    Getting GitOps e-book card

    Learn how to navigate the complex world of modern container-based software development and distribution with Getting GitOps: A Practical Platform with OpenShift, Argo CD, and Tekton.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue