Intro to Argo CD Notifications
If you are using Argo CD for GitOps-style deployment of Kubernetes applications, then you should get notified about the real-time application changes to various environments. In such cases, Argo CD Notifications can be used for providing updates about application deployments or any status change for better collaboration.
This article shows how to configure Argo CD Notifications with the leading collaboration platform Slack.
Intro to Argo CD Notifications
Based on various scenarios, Argo CD Notifications provides a series of triggers to notify users. Examples of use-case in Argo CD when these triggers can be fired:
- Application created
- Application deleted
- Application deployed
- Application health degraded
- Application sync failed
- App sync running
- App sync status unknown
- App sync succeeded
Steps involved while integrating Argo CD Notifications and Slack
Step-1: Create a dedicated slack channel for application delivery status
Create a Slack channel, either public or private, based on your requirement. If you have a channel or a workspace for tracking all the deployment changes, ignore it.
You can create a new app in Slack using this URL. After that, sign in to your Slack account. Refer to the screenshots below.
Now you can click on Create an App
Create an app From scratch(click)
Provide the appname and pick the workspace and then create app
Step-2: Go to OAuth & Permissions settings in Slack
Once the application is created, you can navigate to OAuth & Permissions to be permit Argo CD Notifications to send notification to the channel.
You can go to the Scopes section and add an OAuth Scope. You can read more about the scopes in Slack to understand about users, tokens and bots.
Provide below permissions:
chat:write
chat:write.customize
Once the scope created, Scroll back to the top, click ‘Install to Workspace‘
You should allow your workspace for notifications
Step-3: Copy Slack token into Argo CD Notifications secrets file
Once you allow the app to access the workspace, you will be able to see the Bot User OAuth Token. You need to copy it to local and convert into base64.
You can use the following command to convert the token into base64.
echo -n XXXTOKENXXX | base64
After the encoding, you can edit the secret called argocd-notifications-secret.yaml file, in the namespace where argocd is installed, and use the encoded secret.
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
slack-token:
You can also configure the Slack integration token in configmap file- argocd-notifications-cm
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.slack: |
apiURL: # optional URL, e.g.https://example.com/api
token: $slack-token
username: # optional username
icon: # optional icon for the message (supports both emoij and url notation)
Make sure you have the Argo CD slack template in the same configmap (if installed using helm it will be automatically created). If you want more information about this template contact OpsMx Argo CD experts.
Step-4: Add your application to the required Slack channel
Open Slack, click on channel name-> integrations-> add an App. And then search for your app name and add it. ( refer the screenshot below)
Once added it is notified in the channel.
Step-5: Configure Argo CD application for notifications
After the app is added, you can now configure notification in any Argo CD application. All you need to do is edit the application and add annotation to it. Based on annotations, notifications will be sent to Slack channels.
Examples of Annotations : notifications.argoproj.io/subscribe.on-sync-succeeded.slack: <Channel Name>
————————————————————————
annotations:
notifications.argoproj.io/subscribe.on-deleted.slack: maheshapp-argo-pub
notifications.argoproj.io/subscribe.on-deployed.slack: maheshapp-argo-pub
notifications.argoproj.io/subscribe.on-sync-failed.slack: maheshapp-argo-pub
notifications.argoproj.io/subscribe.on-sync-status-unknown.slack: maheshapp-argo-pub
notifications.argoproj.io/subscribe.on-health-degraded.slack: maheshapp-argo-pub
notifications.argoproj.io/subscribe.on-sync-succeeded.slack: maheshapp-argo-pub
Once annotations are added and application is Synced, stakeholders will in the channel will receive the applications status notifications when any event is triggered.
Conclusion
Collaboration between stakeholders can be enhanced in GitOps-style delivery using Argo CD and Slack integration. If you want to visualize real-time information application deployment and audit information, then explore OpsMx ISD for Argo.
If you have any doubts, please get in touch with Argo CD experts.
0 Comments