Blue-Green Deployments with Argo Rollouts

Requirements

  • ArgoCD

  • Argo Rollouts

Configuration

Create 2 service definitions:

apiVersion: v1
kind: Service
metadata:
  name: demo-app
spec:
  selector:
    app: demo-app
  ports:
    - name: http-web
      appProtocol: http
      port: 80
---
apiVersion: v1
kind: Service
metadata:
  name: demo-app-preview
spec:
  selector:
    app: demo-app
  ports:
    - name: http-web
      appProtocol: http
      port: 80

Create a rollout resource with the following configuration:

A rollout configuration encapulates a replicaset definition. No need to write both the rollout and the replicaset.

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: demo-app
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: demo-app
  template:
    metadata:
      labels:
        app: demo-app
    spec:
      containers:
      - name: demo-app
        image: memogarcia10/demo-app:v3
        imagePullPolicy: Always
        ports:
        - containerPort: 80
  strategy:
    blueGreen: 
      activeService: demo-app
      previewService: demo-app-preview
      autoPromotionEnabled: true
      autoPromotionSeconds: 30

That's it. Now you can deploy a new version of your application by changing the image field in the rollout resource.

Last updated