TechAnek

Kubernetes Progressive delivery with Argo-Rollouts Blue-green deployment

In the dynamic world of modern software development, continuous deployment and high availability are crucial. Argo Rollouts is a tools that facilitate these goals. In this blog, we’ll explore what Argo Rollouts is, the benefits of using Argo Rollouts, and how to implement a Blue-Green deployment using Argo Rollouts.

What is Argo Rollouts?

A Rollout is a type of Kubernetes workload resource that functions similarly to a Kubernetes Deployment object. It is designed to replace a Deployment in situations where more sophisticated deployment or progressive delivery capabilities are required. A Rollout offers several features that a standard Kubernetes Deployment does not provide:

  1. Canary Deployments: Gradually shifts traffic to the new version while monitoring metrics and rollbacks if issues arise.
  2. Blue-Green Deployments: Deploys the new version alongside the old version, then shifts traffic to the new version once it passes all checks.
  3. Progressive Delivery: Combines multiple strategies like canary, blue-green, and experiment-based rollouts for comprehensive control over deployment processes.
  4. integration with ingress controllers and service meshes for advanced traffic routing
  5. integration with metric providers for blue-green & canary analysis
  6. automated promotion or rollback based on successful or failed metrics

Progressive Delivery

Progressive delivery is the process of releasing updates of a product in a controlled and gradual manner, thereby reducing the risk of the release, typically coupling automation and metric analysis to drive the automated promotion or rollback of the update.Progressive delivery is often described as an evolution of continuous delivery, extending the speed benefits made in CI/CD to the deployment process. This is accomplished by limiting the exposure of the new version to a subset of users, observing and analyzing for correct behavior, then progressively increasing the exposure to a broader and wider audience while continuously verifying correctness.

Why Argo Rollouts Should be Used/How can it Help in Application Deployments?

Argo Rollouts enhances Kubernetes’ native deployment strategies by providing:
  • Granular Control – Define custom rollout strategies tailored to your needs.
  • Automated Rollbacks – Automatically revert to the previous version if issues are detected.
  • Detailed Metrics – Integrate with metrics providers to monitor the health of new deployments.
  • Traffic Shifting – Safely direct traffic to new versions incrementally, reducing risk and downtime.

Blue-Green Deployment:

Blue-green deployment is a technique that reduces downtime and risk by running two identical production environments, referred to as Blue and Green. One environment (e.g., Blue) is live and serving all production traffic, while the other (Green) is idle. During an update, the new version of the application is deployed to the idle environment (Green). Once the deployment is successful and validated, traffic is switched from the live environment (Blue) to the new environment (Green). This allows for seamless transitions and easy rollbacks if necessary.

In the context of Argo Rollouts, blue-green deployment is managed by defining a strategy in a Rollout resource. Here’s how it works step-by-step:

  •  
  • Key Components:

    • Active Service (activeService): The Kubernetes Service that routes traffic to the active environment (Blue or Green).
    • Preview Service (previewService): The Kubernetes Service that points to the new environment (Green) during the deployment process.
    • Auto-Promotion (autoPromotionEnabled): Controls whether the new version is automatically promoted to the active environment once deployed. If set to false, manual intervention is required to switch traffic to the new environment.
  • Blue-Green Deployment Workflow in Argo Rollouts:

    • Deploy: Argo Rollouts creates a new ReplicaSet for the new version and updates the Preview Service to point to it.
    • Verify: Perform tests on the new version using the Preview Service.
    • Promote: Manually (or automatically if autoPromotionEnabled is true) switch the Active Service to the new ReplicaSet, effectively routing all traffic to the new version.
    • Scale Down: The old ReplicaSet (Blue) is scaled down, keeping only the new version (Green) running.

Using Argo Rollouts for blue-green deployments provides a controlled and manageable way to deploy updates with minimal downtime and risk, ensuring a smooth transition between application versions.

Install Argo Rollouts with Helm Chart Using Custom Helm Values

  • Add the Argo Helm repository.
				
					helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
				
			
  • Create a values.yaml file to customize the installation:
				
					dashboard:
  # -- Deploy dashboard server
    enabled: true
  # -- Set cluster role to readonly
    readonly: true
  # -- Value of label `app.kubernetes.io/component`
    component: rollouts-dashboard

  ingress:
    enabled: true
    annotations: {}
    labels: {}
    ingressClassName: "nginx"
    hosts: 
      - ARGO-DASHBOARD-SUB-DOMAIN # Replace with your domain

				
			
  • Install Argo Rollouts:
				
					helm install argo-rollouts -n argo-rollouts argo/argo-rollouts -f values.yaml 
				
			
Now you can access Argo Rollouts Dashboard on ARGO-DASHBOARD  domain, or you can use Argo Rollouts CLI
Installing Argo Rollouts CLI:
				
					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

				
			

Deploy Application With Argo Rollouts (Blue-Green Deployment)

We will Install sample application(Rollout, Service, Ingress) and through that we will understand how Blue Green Deployment actually works.

  • rollout.yaml
				
					apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: my-app
  namespace: default
spec:
  replicas: 5
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app-container
          image: argoproj/rollouts-demo:blue
          ports:
            - containerPort: 80
  strategy:
    blueGreen:
      activeService: my-app
      previewService: my-app-preview
      autoPromotionEnabled: true

				
			
  • service.yaml
				
					apiVersion: v1
kind: Service
metadata:
  name: my-app
  namespace: default
spec:
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 80
  type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
  name: my-app-preview
  namespace: default
spec:
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 80
  type: ClusterIP

				
			
  • ingress.yaml
				
					apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-app-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  ingressClassName: nginx
  rules:
    - host: example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: my-app
                port:
                  number: 80

				
			
Apply all above files to deploy the application.
				
					kubectl apply -f rollout.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml
				
			
User can use Argo Rollout CLI or Exposed Dashboard to access deployed Rollouts and its states.
				
					kubectl argo rollouts get rollout my-app
				
			
OR open dashboard in browser,
Now, let’s deploy the Green version of the app using argo rollout cli.
				
					kubectl argo rollouts set image my-app my-app-container=argoproj/rollouts-demo:green
				
			
After Setting, You will be able to see a new set of pods, in the green version too, for our sample application coming up.
After sometime you can see that you have both sets of pods, old(blue) and new (green).
We can see both version’s of application at same time, old (blue) version on my-app service while new (Green) version on my-app-preview service,  we can easily start using new(Green) version on my-app service by Promoting it using argo rollouts cli.
				
					kubectl argo rollouts promote my-app
				
			
Well, You just successfully  used blue-green deployment with Argo Rollouts.

What Will be Achieved After Installing Argo Rollouts

After installing and configuring Argo Rollouts, you will achieve:

  • Automated Blue-Green Deployments: Deploy new versions with minimal downtime and seamless traffic shifting.
  • Enhanced Monitoring: Integrate with Prometheus or other metrics providers to monitor the health of your deployments.
  • Improved Reliability: Automatically rollback to a stable state if issues are detected during deployment.

Conclusion:

Argo Rollouts provide a robust solution for managing Kubernetes deployments. By leveraging advanced deployment strategies like Blue-Green deployments, you can ensure higher availability and reliability for your applications. Follow the steps outlined in this blog to implement a Blue-Green deployment with Argo Rollouts, enhancing your deployment process and minimizing downtime.

Argo Rollouts is a powerful tool that,  can significantly streamline your Kubernetes deployment workflows. Try it out and experience the benefits of advanced deployment strategies in your applications!

Leave a Reply

Your email address will not be published. Required fields are marked *