ArgoCD Notifications is your friend when you need to notify deployment status from your Sitecore K8 cluster

Hello, fellow Sitecore developers. I hope life is good. If not, then it’s time to make your life good. Go out there and seize the moment, your moment 🙂

Today’s post is about ArgoCD NotificationsArgoCD is your true friend in a GitOps world, and what I love about Argo is that they have so many exciting projects:

And today, we will dive into ArgoCD Notifications 🙂

The idea is that we want to notify our team members when there is a new deployment. We can use tools like Github Actions or Azure Pipelines( Is it still a thing 😉 ). But since we are in the GitOps world and are already using ArgoCD, the natural choice will be ArgoCD Notifications 🙂

So what is ArgoCD Notifications?

Argo CD Notifications continuously monitors Argo CD applications and provides a flexible way to notify users about important changes in the application state. Using a flexible mechanism of triggers and templates you can configure when the notification should be sent as well as notification content. Argo CD Notifications includes the catalog of useful triggers and templates. So you can just use them instead of reinventing new ones.

Great explanation, ArgoCD. Let’s move on 🙂

To install/set up ArgoCD Notifications, let’s follow the instructions at https://argocd-notifications.readthedocs.io/en/stable/.

We will install the controller:

kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/release-1.0/manifests/install.yaml

We should also install Triggers and Templates.
Argo CD Notifications includes the catalog of useful triggers and templates. So you can just use them instead of reinventing new ones

kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/release-1.0/catalog/install.yaml

Hold on a minute! How do we want to notify our team members? ArgoCD Notfications integrates with many “message services”:

Let’s go for Slack this time 🙂

We need to create a slack app and generate an OAuth token. (That is how we integrate ArgoCd Notifications with the slack app)

Ok, let us quickly create a slack App.
Navigate to:

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

*We have already created a workspace

We select “From scratch”, when creating the new App. Here we give the app a name, let’s call it SitecoreKube. And lastly connect the app to a workspace.

Next will be to create the OAuth token.
We will navigate to Enter OAuth & Permissions in the menu, and select the option Permissions. Here we will add two scopes:
chat:write
chat:write.customize

Ok, let’s scroll back to the top and click Install App to Workspace to confirm the installation.
Success! We have an OAuth token 🙂

We have one more thing to do, and that is to add the newly created app to a slack channel. Let’s add it to the channel, test-environment.
*If we don’t do this, we will NOT receive any notifications

Wonderful, the Slack stuff is done 🙂

Let’s continue with some serious K8 stuff 😉

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

First up is to update the secret, argocd-notifications-secret. Here we update it with our OAuth token(slack).

apiVersion: v1
kind: Secret
metadata:
  name: argocd-notifications-secret
data:
  slack-token: <base64 encoded oauth-token>

*Don’t forget to convert it to stringase64, you can easily do it with a linux command(I wish there was something similar in Powershell 😉 )

echo -n  xoxb-secretstuffandsoon | base64

Next is to update the configmap,  argocd-notifications-cm. Here are all the message templates and triggers. What is missing is service.slack, let’s add it to the data section:

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
  namespace: argocd
data:
  service.slack: |
    token: $slack-token

We are almost done 🙂

We have one more thing to do, and that is to update our ArgoCD applications. We need to add annotations for the ArgoCD Notifications, let’s start with sync-succeeded and sync-failed. And specify the Slack channel that should receive the notifications 🙂

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: nextjsproxy-someapp
  namespace: argocd
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.slack: test-environment  #Slack Channel name
    notifications.argoproj.io/subscribe.on-sync-failed.slack: test-environment  #Slack Channel name 
    

Hallelujah friends!
Next time the application is Synced, we should receive the application status in our slack channel, test-environment.

And there it is people!

That’s all for now folks 😊


One thought on “ArgoCD Notifications is your friend when you need to notify deployment status from your Sitecore K8 cluster

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.