# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://memogarcia.gitbook.io/continuous-learning/projects/argo-blue-green-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
