반응형
개요
ArgoCD에서 배포 및 상태에 대해서 Notification 받을 수 있습니다.
Slack - ArgoCD Application 생성
1. ArgoCD Application 생성
- Slack Application Create 페이지 접속
- Create an app → From scratch 클릭
- Application 생성하기
- Scopes 등록
- OAuth & Permissions 클릭
- Scopes → chat:write , chat:write.customize 클릭

- OAuth Token 등록


ArgoCD Notification 구성
1. Slack Token Secret 배포
vi argocd-notifications-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
notifiers.yaml: |
slack:
token: <여기에 "Bot User OAuth Token"을 입력합니다>
kubectl apply -f argocd-notifications-secret.yaml -n argocd
1. ArgoCD Notification POD 배포
- Alert를 보내주는 역할
- 파일 위치 : https://github.com/xxx/argo-cd/argocd-notifications
kubectl apply -f argocd-notifications-deploy.yaml -n argocd
# 사용안함 kubectl apply -f https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/release-1.0/manifests/install.yaml -n argocd
2. ArogoCD Notification template ConfigMap 배포
- 조건에 맞을 때 Alert를 보내줄 수 있게 정의하는 역할
- 파일 위치 : https://github.com/xxx/argo-cd/argocd-notifications
kubectl apply -f template-configmap.yaml -n argocd
# 사용안함 kubectl apply -f https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/release-1.0/catalog/install.yaml -n argocd
3. argoCD application에 slack chanel 등록해주기
k get app -n argocd
k edit app -n argocd nginx-dean(application name)
metadata:
annotations:
notifications.argoproj.io/subscribe.on-deployed.slack: argocd-deploy
notifications.argoproj.io/subscribe.on-health-degraded.slack: argocd-deploy
notifications.argoproj.io/subscribe.on-sync-failed.slack: argocd-deploy
notifications.argoproj.io/subscribe.on-sync-running.slack: argocd-deploy
notifications.argoproj.io/subscribe.on-sync-status-unknown.slack: argocd-deploy
notifications.argoproj.io/subscribe.on-sync-succeeded.slack: argocd-deploy
# 다른 application 모두 등록 필요.
k get app -n argocd
Slack chanel 등록 스크립트 작성 방법
- app list 파일 생성
kubectl get app -n argocd |awk '{print $1}' |grep -v NAME > list.txt
- scripts 파일 생성
vi app.sh
#!/bin/bash
for app_name in `cat list.txt`
do
echo $app_name
kubectl patch app $app_name -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-health-degraded.slack":"deploy_notication"}}}' --type merge
kubectl patch app $app_name -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-running.slack":"deploy_notication"}}}' --type merge
kubectl patch app $app_name -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-status-unknown.slack":"deploy_notication"}}}' --type merge
kubectl patch app $app_name -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-succeeded.slack":"deploy_notication"}}}' --type merge
done
5. Slack Notification Trigger 종류

6. Slack Notification TEST
ArgoCD에서 SYNC 버튼 클릭
Notification 성공

반응형
'CICD 배포 > CICD 배포' 카테고리의 다른 글
ArgoCD Vs Spinnaker 비교 (0) | 2023.02.09 |
---|---|
CD - Spinnaker - Artifact (0) | 2023.02.09 |
[ ArgoCD ] Deploy (0) | 2023.02.08 |
[ ArgoCD ] application 생성 (0) | 2023.02.08 |
[ ArgoCD ] 구성 (0) | 2023.02.08 |