ArgoCD NotificationsでMS Teamsに通知する方法

今回の内容

ArgoCD notificationsでMS temasに通知するときに詰まった点について記載していきます。

事前準備

ArogCDは事前"Getting start"でインストールにしていると想定しています。

argo-cd.readthedocs.io

ArgoCD Notificationの準備

ArgoCDのStable版(V1.0)でMS TeamsへのNotificationがサポートされいるように見えますが、実はv1.0ではサポートされていません。Notificationのテンプレートを確認するとEmailとslackはサポートしていますがMS Teamsのテンプレートが含まれていません。
なのでv.1.1.0を使いましょう

f:id:mo121_7:20211213203044p:plain

Install ArgoCD Notification and Template

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

通知の設定

Setp:
1 argocd-notifications-secret.yamlを作成

apiVersion: v1
kind: Secret
metadata:
  name: argocd-notifications-secret
stringData:
  channel-teams-url: <your-webhook-url>

kubectl appy -f argocd-notifications-secret.yaml

2 argocd-notifications-cmを更新

kubectl edit configmap argocd-notifications-cm -n argocd

Dataの下に追加
data:
  service.teams: |
    recipientUrls:
      channelName: $channel-teams-url

3 パイプライン一覧を確認

$ kubectl get Application -n argocd
NAME   SYNC STATUS   HEALTH STATUS
test   OutOfSync     Healthy

4 アノテーションを追加

$  kubectl edit Application test -n argocd
metadata:
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.teams: channelName

これでArgoCDがSyncしたときにMS Teamsに通知ができるようになる 通知のタイミングはドキュメントを確認

argocd-notifications.readthedocs.io