ArgoCD Slack Notification Setup

gaurav agnihotri
4 min readJan 11, 2023

--

Receive notifications for all your Argo moves :)

ArgoCD Sends Notification to Slack

1- Create a Slack app using the below URL.

https://api.slack.com/apps?new_app=1

Click on Create New App -

Then Choose “From Scratch”

Fill in the App name, such as “argocd,” and select your Slack workspace as below.

Once application is created navigate to Enter OAuth & Permissions & Choose Permissions

Now, add a scope for this Bot (argocd app), so select Two scopes for the time being.

Bot Permission

Once Scope is configured, Scroll back to the top, click ‘Install App to Workspace’ button and confirm the Installation.

Once installation is completed copy the OAuth token.

Copy the Auth Token and keep it somewhere safe.

2- Now Create a Slack Channel — for example argocd

Important- Browse your argocd channel and add the bot you created in the previous step, in this case, the bot name is “argocd”

### If you forget to add this, you will NOT receive notifications. ###

Add your Bot to your Slack channel if you want to receive notifications

After adding the Bot to the Slack channel. We need to make some changes to our ArgoCD configuration files.

3- ArgoCD Config Changes.

Assuming your slack token is — xoxp-12345678912345–5467834251-jGQASEDJGNCDHTIv9ZcY

In your argocd configuration, look for the Secret argocd-notifications-secret.

apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
slack-token: "xoxp-12345678912345–5467834251-jGQASEDJGNCDHTIv9ZcY"

The above file is called argocd-notifications-secret.yaml.

Now Apply—

kubectl apply -f argocd-notifications-secret.yaml

Finally, use the OAuth token to configure the Slack integration-

apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.slack: |
token: $slack-token # use as it is
defaultTriggers: |
- on-deployed
trigger.on-deployed: |
- description: Application is synced and healthy. Triggered once per commit.
oncePer: app.status.operationState.syncResult.revision
send:
- app-deployed
when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy' and app.status.sync.status == 'Synced'
template.app-deployed: |
message: |
{{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} is now running new version of deployments manifests.
slack:
attachments: |
[{
"title": "{{ .app.metadata.name}}",
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
"color": "#18be52",
"fields": [
{
"title": "Sync Status",
"value": "{{.app.status.sync.status}}",
"short": true
},
{
"title": "Repository",
"value": "{{.app.spec.source.repoURL}}",
"short": true
},
{
"title": "Revision",
"value": "{{.app.status.sync.revision}}",
"short": true
}
{{range $index, $c := .app.status.conditions}}
{{if not $index}},{{end}}
{{if $index}},{{end}}
{
"title": "{{$c.type}}",
"value": "{{$c.message}}",
"short": true
}
{{end}}
]
}]

The above file is called argocd-notifications-cm.yaml

Now Apply —

kubectl apply -f argocd-notifications-cm.yaml

Create a Slack integration subscription:

Open your service application file, such as the one below, and add the slack annotation.

annotations:
notifications.argoproj.io/subscribe.on-deployed.slack: argocd #Slack Channel name
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ms-echoserver-application
namespace: argocd
annotations:
notifications.argoproj.io/subscribe.on-deployed.slack: argocd #Slack Channel name

argocd-image-updater.argoproj.io/image-list: myalias=gcr.io/project01/ms-echoserver:dev #Write repository name
argocd-image-updater.argoproj.io/myalias.pull-secret: pullsecret:argocd/argocd-gcr-secret # You can remove this annotation if you have already configured the gcr secret and are using the same secret to retrieve all GCR images in your deployments.
argocd-image-updater.argoproj.io/myalias.update-strategy: digest #There are several ways to update the image, but I'm using digest.
argocd-image-updater.argoproj.io/write-back-method: git # We don't need the secret as mentioned in argocd doc because we already set it up via argocd console if you're using the same git repo.
argocd-image-updater.argoproj.io/git-branch: main
argocd-image-updater.argoproj.io/myalias.force-update: "true"

All done .

Testing -

Now deploy your service and test the notification. I am deploying ms-echoserver-application.

slack Notification

Click Me-

ArgoCD All-in-One Setup Guide.

ArgoCD High Availability (HA) [Production Ready].

ArgoCD Ingress Setup

ArgoCD Okta Setup.

ArgoCD Image updater

ArgoCD Resource Hooks.

I hope this post is informative and useful for you :)

Crafting these articles demands countless hours of ideation, research, and writing. This year has seen me invest over 500 hours into this craft alone. If my work has brought you joy, would you kindly consider supporting me with a coffee? Your gesture would mean the world to me. If not, thank you dearly for your readership. ❤️

Buy-me-a-coffee ❤️

--

--