Argo CD to Slack Notifications: The Complete Setup Guide
This document outlines the step-by-step process to configure Argo CD to send rich, detailed notifications to Slack whenever an application syncs, fails, or degrades.β Prerequisites
- Argo CD installed on your Kubernetes cluster.
- Admin access to a Slack Workspace.
kubectlaccess to your cluster.
1. Configure Slack App & Bot Token
We need to create a βBotβ user that Argo CD can use to post messages.- Go to Slack API: Your Apps.
- Click Create New App > From Scratch.
- Name it βArgoCDβ and select your workspace.
- In the left sidebar, go to OAuth & Permissions.
- Scroll down to Scopes > Bot Token Scopes and add the following permission:
chat:write(Required to send messages)chat:write.customize(Optional: Allows changing username/icon dynamically)
- Scroll up to the top of the page and click Install to Workspace.
- Copy the Bot User OAuth Token (starts with
xoxb-...).
β οΈ Important: Invite the Bot
For the bot to post in a channel, it must be a member of that channel.- Go to your target Slack channel (e.g.,
#jenkins-ntfy). - Type
/invite @ArgoCDand hit Enter.
2. Create the Kubernetes Secret (Safely)
We must store the Slack token in a Kubernetes Secret. CRITICAL: We useecho -n to prevent hidden newline characters (\n) from breaking the configuration.
Run this command in your terminal (replace xoxb-YOUR-TOKEN with your actual token):
3. Configure Argo CD Notifications
We will configure theargocd-notifications-cm ConfigMap. This defines Service, Triggers, Subscriptions, and the Message Templates.
Features of this Configuration:
- Rich Formatting: Uses Slack Attachments for a professional βCloudWatchβ look.
- Detailed Info: Lists Repo URL, Commit SHA, and Sync Status.
- Resource List: loops through changed objects (e.g.,
Service my-svc -> configured) so developers see exactly what changed. - Deep Links: Clickable titles take you directly to the Argo CD dashboard.
π argocd-notifications-cm.yaml
Save the following content to a file named argocd-notifications-cm.yaml.
**Update the argocdUrl** at the top with your actual Argo CD domain.
4. Apply and Restart
Apply the configuration and restart the controller to force it to reload the settings.5. Verification
- Check the logs to ensure no YAML errors:
- Go to the Argo CD UI.
- Click Sync on any application.
- Check your Slack channel. You should see a detailed card listing the sync status and the specific objects (Pods/Services) that were updated.
π§ Troubleshooting Guide (Common Issues)
| Issue | Cause | Fix | |
|---|---|---|---|
Error: yaml: line 2: mapping values are not allowed | Hidden Newline in Secret. The Slack token has a \n at the end. | Delete secret and recreate using echo -n "token". | |
Error: template: unexpected ".0" in operand | Invalid Go Template Syntax. Accessing arrays like .history.0 is not allowed. | Use index .history 0 or remove the field (as we did in the final config). | |
Slack: <<no value>/applications/...> | Missing Context URL. The template cannot generate links because it doesnβt know your domain. | Add `context: | argocdUrl: https://β¦` to the ConfigMap. |
| Boot Loop / Crash | YAML Formatting. Using colons inside values without quotes (e.g., icon: :rocket:). | Remove the icon line or quote it properly "icon": ":rocket:". |
ArgoSecret.yaml
Restart Services
