In a previous post: ArgoCD email notifications with Gmail, I set up email notifications for ArgoCD. Recently, in the process of setting up Remark42, I learned that both services support Slack notifications as well.
Personally, I think there are a few advantages to using Slack notifications over email:
- Faster: Slack notifications are usually faster than emails.
- Channel separation: You can create a separate channel for notifications. For example, having one for production and another for staging environment.
- Slack bots: They are easy to create, and have a nice UI to configure them.
This will be a post about setting up a Slack bot, and configuring ArgoCD and Remark42 to send notifications with it.
Slack bot
First step is to create a Slack channel. I have created one for all my homelab related stuff. If you don’t have one yet, head over to Slack and create one.
Next, create a Slack app here: Create an App. Example:
Go to “OAuth & Permissions” section and add the following scopes:
Install the app to your workspace.
Copy the “Bot User OAuth Token” from the “OAuth & Permissions” section. This will be used by ArgoCD and Remark42 to interact with the bot.
Lastly, on Slack, invite the bot to the channel you want to receive notifications in. I have invited mine to “production” and “staging” channels in my workspace.
ArgoCD configuration
Official docs: Slack
First, if you haven’t already, install ArgoCD notifications controller.
|
|
Then deploy this secret to your ArgoCD namespace:
|
|
To let notifications controller use the token, add the followig to argocd-notifications-cm
configmap data:
|
|
In the same configmap, also add the following “defaultTriggers” field. Since I want to use the same set of triggers for multiple applications, I find this to be a easy way to set up.
|
|
To use these triggers, edit an ArgoCD application manifest and add the following:
|
|
For the slack channel, I used “production” and “staging” as mentioned earlier.
Optional: edit the default templates specified in the same configmap, as shown in the official docs.
Now test it by syncing an application. You should see a notification in the specified Slack channel.
Remark42 configuration
Official docs: Notification
For Remark42, essentially we just need three environment variables to be set. Since I’m using Kustomize, I declared them like this:
|
|
And in the deployment manifest, I added the following to the environment variables:
|
|
Test it by posting a comment. You should see a notification in the specified Slack channel.