# Argo CD deployment pipeline

With ilert Deployment integration for [Argo CD](https://argoproj.github.io/), you can display your deployment pipelines in ilert and enrich alerts’ context. Real-time visibility helps you quickly assess whether a recent deployment triggered an incident. This instant insight is essential for identifying issues as they occur, allowing for a faster response and minimizing downtime.

## Setting up

### Creating your deployment pipeline in ilert

In any way, a pipeline is required, which will also generate a new `integrationKey` required to route deployment events when they occur. Head to your ilert account and navigate to **Alert sources -> Deployment events.**

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FnhH9w4JnhladFffBTn95%2Fimage.png?alt=media&#x26;token=88fea6d2-29c6-4fe2-84a6-cffaf279aa11" alt=""><figcaption></figcaption></figure>

Head over to the deployment pipelines tab and click on **Create new pipeline.**

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FTV3ugSlHNj9zn9nPaK4D%2Fimage.png?alt=media&#x26;token=97067e0f-50b5-457e-b9eb-134977c07bdd" alt=""><figcaption></figcaption></figure>

Provide a name for your pipeline.

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FieiWetkItk80jeQK7tVH%2F1.png?alt=media&#x26;token=c3cc5e75-3d0d-41b1-b60b-3108bb6ac1fd" alt=""><figcaption></figcaption></figure>

By clicking on Create, you should end up on the detail view of your Argo CD deployment pipeline.

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2F8u7gboUUXxekUBwhHjuZ%2F2.png?alt=media&#x26;token=4e2a4a6a-a3fd-4f33-850a-f0da9ba5c86b" alt=""><figcaption></figcaption></figure>

Providing you with a freshly generated `integrationKey` and copy & pastable **URL** ready for your webhook setup.

### Configure the notification controllers configmap in Argo CD

Locate the notification controllers configmap in your setup.

Add following under `data` in the configmap and enter your :

```yaml
service.webhook.ilert: |
    url: <YOUR-ARGO-CD-PIPELINE-URL>
    headers:
      - name: "Content-Type"
        value: "application/json"

  template.ilert-app-sync-template: |
    webhook:
      ilert:
        method: POST
        body: |
          { 
            "app": {{ toJson .app }},
            "commit": {{ if .app.status.sync.revision }}{{ call .repo.GetCommitMetadata .app.status.sync.revision | toJson }}{{ else }}null{{ end }},
            "repositoryName": "{{ call .repo.FullNameByRepoURL .app.spec.source.repoURL }}"
          }

  template.ilert-app-deleted-template: |
    webhook:
      ilert:
        method: POST
        body: |
          { 
            "app": {{ toJson .app }},
            "repositoryName": "{{ call .repo.FullNameByRepoURL .app.spec.source.repoURL }}"
          }

  trigger.on-deployed: |
    - when: app.status.operationState.phase in ['Error', 'Failed', 'Succeeded']
      send: [ilert-app-sync-template]

  trigger.on-app-deleted: |
    - when: app.metadata.deletionTimestamp != nil
      send: [ilert-app-deleted-template]
```

An example for the full file could be:

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
  namespace: argocd
data:
  service.webhook.ilert: |
    url: <YOUR-ARGO-CD-PIPELINE-URL>
    headers:
      - name: "Content-Type"
        value: "application/json"

  template.ilert-app-sync-template: |
    webhook:
      ilert:
        method: POST
        body: |
          { 
            "app": {{ toJson .app }},
            "commit": {{ if .app.status.sync.revision }}{{ call .repo.GetCommitMetadata .app.status.sync.revision | toJson }}{{ else }}null{{ end }},
            "repositoryName": "{{ call .repo.FullNameByRepoURL .app.spec.source.repoURL }}"
          }

  template.ilert-app-deleted-template: |
    webhook:
      ilert:
        method: POST
        body: |
          { 
            "app": {{ toJson .app }},
            "repositoryName": "{{ call .repo.FullNameByRepoURL .app.spec.source.repoURL }}"
          }

  trigger.on-deployed: |
    - when: app.status.operationState.phase in ['Error', 'Failed', 'Succeeded']
      send: [ilert-app-sync-template]

  trigger.on-app-deleted: |
    - when: app.metadata.deletionTimestamp != nil
      send: [ilert-app-deleted-template]
```

Now add an annotation to your apps you want to receive a notification from by creating a subscription in your app.

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    notifications.argoproj.io/subscribe.on-deployed.ilert: ""
    notifications.argoproj.io/subscribe.on-app-deleted.ilert: ""
```

Test the integration by syncing your app.<br>
