> For the complete documentation index, see [llms.txt](https://memogarcia.gitbook.io/continuous-learning/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://memogarcia.gitbook.io/continuous-learning/projects/argo-blue-green-deployment.md).

# Blue-Green Deployments with Argo Rollouts

## Requirements

* ArgoCD
* Argo Rollouts

## Configuration

Create 2 service definitions:

```yaml
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.

```yaml
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.
