Skip to main content

ArgoCD

CatalogScorecards

Summary

ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. You can use ArgoCD to drive insights into values such as:

  • Deploys

Setup

Notification webhooks

To send Cortex information about syncs in ArgoCD, you can use ArgoCD notification Webhooks to call the Cortex flexible deploy REST endpoint.

Here is an example of what a argocd-notifications-cm config map may look like:

apiVersion: v1
kind: ConfigMap
data:
context: |
argocdUrl: https://argo.company.com
service.webhook.cortex-webhook: |
url: https://api.getcortexapp.com
headers:
- name: Content-Type
value: application/json
- name: Accept
value: application/json
- name: Authorization
value: Bearer $token
subscriptions: |
- recipients:
- cortex-webhook
triggers:
- on-sync-succeeded
template.app-sync-succeeded: |
webhook:
cortex-webhook:
method: POST
path: /api/v1/catalog/{{.app.metadata.name}}/deploys
body: |
{ "customData": { "Sync Status": "{{.app.status.sync.status}}","Sync Details": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true" },
"environment": "{{.app.spec.destination.name}}",
"sha": "{{.app.status.operationState.operation.sync.revision}}",
"timestamp": "{{.app.status.operationState.finishedAt}}",
"title": "Sync by ArgoCD",
"type": "DEPLOY"
}
trigger.on-sync-succeeded: |
- send:
- app-sync-succeeded
when: app.status.operationState.phase in ['Succeeded']


The above example assumes your ArgoCD application's name matches the x-cortex-tag. In this case, each application in ArgoCD can subscribe to the same trigger.

If your application name doesn't match the x-cortex-tag, add a value/pair to the info section of the Application manifest. Then, instead of using .app.metadata.name in the url, use .app.spec.info[0].value.

Subscribing application to webhooks

The last step is to subscribe your application to the webhook. You do this by adding a label annotation in the Application spec in the following format:

    notifications.argoproj.io/subscribe.<trigger-name>.<webhook-name>: ""

For example, if we want to subscribe an application to the example webhook above, our Application yaml may look something like this:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
notifications.argoproj.io/subscribe.on-sync-succeeded.cortex-webhook: ""
...