Sowing Discord (Notifications) with Argo CD
As I worked on rebuilding my Kubernetes
cluster, I wanted to enable Discord
notifications to stay abreast of what was happening with my Argo CD
Applications, so I
added Argo CD
Notifications
(a separate project at the time). I tried Discord’s Slack-Compatible
Webhook.
That didn’t work: Argo CD would always append postMessage.chat
(or was it chat.postMessage
?) to
the provided URL, with no way to change it. Further exploration revealed that I was using the
wrong endpoint, as /slack
is for webhooks from Slack.
I switched to /webhook
. Now I couldn’t get it to send the custom rich template I’d defined in the
ConfigMap, because triggers are associated with specific templates and the ones in the
catalog (one of which I was using)
were bundled with their own templates.
I duplicated the triggers from the catalog for use with my own templates and was soon receiving Discord notifications. I initially saw many errors about not being able to fetch from GitLab, but there were also notifications about the sync succeeding.
At a later point, I switched to using the Argo CD Notifications Helm chart so that I didn’t have to put my webhook URL and other details in the clear in a ConfigMap. I suddenly realized I was no longer receiving notifications.
There were two reasons. First, I’d put $discord-webhook-path
in the templates
section, which
doesn’t support variable interpolation; moving it to
services
fixed that. Second, the Helm chart added an app.kubernetes.io/name: argocd-notifications
label,
but argocd-repo-server only allowed traffic from
argocd-notifications-controller
.
I got around that by overriding the release
name.
Once I could see it working, I put a regenerated webhook URI in the Secret.