In this article we are going to cover Create App in Slack, create channel in slack and How to Integrate ArgoCD Notifications with Slack for Real time notifications.
Integrating ArgoCD with Slack allows you to receive real-time notifications about deployments and application health directly in your Slack channels
Prerequisites:
- Minikube Installed
- An ArgoCD cluster
- A Slack workspace
Table of Contents
Step #1:Create a Slack App
Go to the Slack API page and create a new app.
Choose a name for your app (e.g., “ArgoCD Notifications“) and select your Slack workspace.
Under OAuth & Permissions
add the following scopes:
chat:write
chat:write
.customize
Install the app to your workspace
Click on “Allow“.
copy the generated Bot User OAuth Token.
Step #2:Create New Slack Channel
Create a New slack Channel For Ex. “k8s-deployment-status“
Click on Add an App to add above “ArgoCD Notifications” app into slack channel
Select the App and Click on “Add“.
Step #3:Install ArgoCD Notifications (if not already installed):
You can install ArgoCD Notifications using the provided installation method based on your deployment (manifest, operator, or Helm) from ArgoCD Notifications official page.
Step #4:Configure ArgoCD Notifications with Slack
Edit the argocd-notifications
service manifest and provide the following details or you can create new secret as shown below
Slack token: The Bot User OAuth Token from step 1.
Slack channel: The name of the channel where you want to receive notifications (e.g., “#k8s-deployment-status“).
sudo nano argocd-notifications-secret.yaml
paste the below code, add slack tocken from step 1
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
namespace: argocd
stringData:
slack-token: "xoxb-"
Apply the above secret yaml
kubectl apply -f argocd-notifications-secret.yaml
use the OAuth token to configure the Slack integration in the argocd-notifications-secret
secret in configmap
sudo nano argocd-notifications-cm.yaml
Paste the below code.
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}}
]
}]
apply the above yaml
kubectl apply -f argocd-notifications-cm.yaml
Step #4:Configure Application Notifications (optional):
Annotations can be added to individual applications within ArgoCD to specify notification preferences:
argocd-notifications.argoproj.io/channels
: Comma-separated list of Slack channels to notify.
Other annotations like argocd-notifications.argoproj.io/kinds
and argocd-notifications.argoproj.io/resources
can be used to filter notifications based on resource types and kinds.
Create Application in ArgoCD and add slack channel to test argocd notifications with slack channel
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: go-app
namespace: argocd
annotations:
notifications.argoproj.io/subscribe.on-deployed.slack: k8s-deployment-status
notifications.argoproj.io/subscribe.on-sync-failed.slack: k8s-deployment-status
notifications.argoproj.io/subscribe.on-sync-succeeded.slack: k8s-deployment-status
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
destination:
name: 'in-cluster'
namespace: 'default'
source:
path: 'chart'
repoURL: 'https://github.com/devopshint/gitops-workflow-deploy-goapp-minikube-using-argocd'
targetRevision: HEAD
helm:
valueFiles:
- values.yaml
project: 'default'
syncPolicy:
syncOptions:
- CreateNamespace=false
Apply the above Application in ArgoCD, once application is deployed, you will receive deployment status in slack channel
Conclusion:
In this article we have covered Create App in Slack, Create Channel in Slack, integrate ArgoCD Notifications with slack.
Related Articles:
How to Deploy Application on Minikube using ArgoCD UI
Reference:
A detailed guide with explanations and visuals can be found on ArgoCD Notifications official page