๐น Argo CD Notifications๋?
Argo CD Notifications๋ Argo CD์์ ๋ฐ์ํ๋ ์ด๋ฒคํธ(๋ฐฐํฌ ์ฑ๊ณต, ์คํจ, ๋๊ธฐํ ์ค๋ฅ ๋ฑ)๋ฅผ ์ค์๊ฐ์ผ๋ก ์๋ฆผํ๋ ๊ธฐ๋ฅ์
๋๋ค.
์ด๋ฅผ ํ์ฉํ๋ฉด ์ด์์๊ฐ ๋ฐฐํฌ ์ํ๋ฅผ ๋น ๋ฅด๊ฒ ํ์
ํ๊ณ ์ฆ์ ๋์ํ ์ ์์ผ๋ฉฐ,
Slack, ์ด๋ฉ์ผ, ์นํ
(Webhook) ๋ฑ ๋ค์ํ ์ฑ๋๋ก ์๋ฆผ์ ๋ณด๋ผ ์ ์์ต๋๋ค.
โ
Argo CD Notifications์ ์ฃผ์ ๊ธฐ๋ฅ
โ ์ ํ๋ฆฌ์ผ์ด์
๋๊ธฐํ ์ํ ๋ณ๊ฒฝ ๊ฐ์ง (Sync ์ฑ๊ณต, ์คํจ, ์ถฉ๋ ๋ฑ)
โ ์ ํ๋ฆฌ์ผ์ด์
ํฌ์ค ์ฒดํฌ ์คํจ ๊ฐ์ง (์: CrashLoopBackOff)
โ Slack, ์ด๋ฉ์ผ, Webhook ๋ฑ์ ์๋ฆผ ์ฑ๋ ์ง์
โ ์ปค์คํ
์๋ฆผ ํ
ํ๋ฆฟ ๊ตฌ์ฑ ๊ฐ๋ฅ
๐น Argo CD Notifications ์ค์น ๋ฐ ๊ตฌ์ฑ
โ 1. Argo CD Notifications ์ค์น
Argo CD Notifications๋ Argo CD์ ํ์ฅ ๊ธฐ๋ฅ์ด๋ฏ๋ก Helm์ ์ฌ์ฉํ์ฌ ์ค์นํฉ๋๋ค.
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
helm upgrade --install argo-cd argo/argo-cd --namespace argocd --set notifications.enabled=true
โ ์ค์น ํ์ธ:
kubectl get pods -n argocd | grep notifications
argocd-notifications-controller-xxxxx 1/1 Running 0 1m
โ 2. Argo CD Notifications ๊ธฐ๋ณธ ์ค์
Argo CD Notifications๋ ConfigMap๊ณผ Secret์ ํตํด ์๋ฆผ ์ค์ ์ ๊ด๋ฆฌํฉ๋๋ค.
๐ ConfigMap ์์ฑ (notifications-config)
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
namespace: argocd
data:
context: |
appName: "ArgoCD"
templates.app-sync-failed: |
title: Application {{.app.metadata.name}} ๋๊ธฐํ ์คํจ
body: |
โ {{.app.metadata.name}} ์ ํ๋ฆฌ์ผ์ด์
์ด ๋๊ธฐํ์ ์คํจํ์ต๋๋ค.
- **ํ๋ก์ ํธ**: {{.app.spec.project}}
- **๋๊ธฐํ ์ํ**: {{.app.status.sync.status}}
- **๊ฑด๊ฐ ์ํ**: {{.app.status.health.status}}
subscriptions: |
- recipients:
- slack:#deploy-alerts
triggers:
- on-sync-failed
โ
์ค๋ช
:
โ context → ์๋ฆผ์ ํฌํจ๋ ๊ธฐ๋ณธ ์ ๋ณด ์ค์
โ templates.app-sync-failed → ๋๊ธฐํ ์คํจ ์ ์๋ฆผ ๋ฉ์์ง ํ
ํ๋ฆฟ
โ subscriptions → ํน์ ์ด๋ฒคํธ ๋ฐ์ ์ Slack ์ฑ๋์ ์๋ฆผ
โ 3. Slack ์๋ฆผ ์ค์
๐ Slack Webhook ์ค์
Slack ์๋ฆผ์ ๋ฐ๊ธฐ ์ํด Webhook์ ์ค์ ํด์ผ ํฉ๋๋ค.
1๏ธโฃ Slack Webhook ์์ฑ ํ์ด์ง๋ก ์ด๋
2๏ธโฃ ์๋ก์ด Slack App์ ์์ฑ ํ Incoming Webhooks ํ์ฑํ
3๏ธโฃ Webhook URL์ ๋ณต์ฌ
๐ Slack Webhook์ Kubernetes Secret์ ์ ์ฅ
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
namespace: argocd
stringData:
slack-webhook-url: "https://hooks.slack.com/services/XXXX/XXXX/XXXX"
โ Secret ์ ์ฉ:
kubectl apply -f argocd-notifications-secret.yaml
๐ ConfigMap์ Slack ์ค์ ์ถ๊ฐ
Slack Webhook์ ์๋ฆผ ์ฑ๋๋ก ์ถ๊ฐํฉ๋๋ค.
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
namespace: argocd
data:
service.slack: |
webhook: $slack-webhook-url
โ ConfigMap ์ ์ฉ:
kubectl apply -f argocd-notifications-cm.yaml
โ Slack ์๋ฆผ ํ ์คํธ:
argocd notifications test-service slack
โ 4. ์ด๋ฉ์ผ ์๋ฆผ ์ค์
์ด๋ฉ์ผ ์๋ฆผ์ ๋ฐ๊ธฐ ์ํด SMTP ์๋ฒ ์ ๋ณด๋ฅผ Secret์ผ๋ก ์ ์ฅํฉ๋๋ค.
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
namespace: argocd
stringData:
email-username: "example@gmail.com"
email-password: "app-password"
โ Secret ์ ์ฉ:
kubectl apply -f argocd-notifications-secret.yaml
๐ ConfigMap์ ์ด๋ฉ์ผ ์ค์ ์ถ๊ฐ
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
namespace: argocd
data:
service.email: |
host: smtp.gmail.com
port: 587
username: $email-username
password: $email-password
from: "ArgoCD Notifications <example@gmail.com>"
โ ConfigMap ์ ์ฉ:
kubectl apply -f argocd-notifications-cm.yaml
โ ์ด๋ฉ์ผ ์๋ฆผ ํ ์คํธ:
argocd notifications test-service email
โ 5. Argo CD ์๋ฆผ ํธ๋ฆฌ๊ฑฐ ์ค์
๋ค์ํ ์ด๋ฒคํธ์ ๋ํ ์๋ฆผ์ ์ค์ ํ ์ ์์ต๋๋ค.
๐ ์ ํ๋ฆฌ์ผ์ด์ ๋๊ธฐํ ์ฑ๊ณต/์คํจ ํธ๋ฆฌ๊ฑฐ ์ค์
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
namespace: argocd
data:
trigger.on-sync-failed: |
- description: "์ ํ๋ฆฌ์ผ์ด์
๋๊ธฐํ ์คํจ ๊ฐ์ง"
when: "app.status.sync.status == 'OutOfSync'"
send: [slack, email]
trigger.on-sync-succeeded: |
- description: "์ ํ๋ฆฌ์ผ์ด์
๋๊ธฐํ ์ฑ๊ณต ๊ฐ์ง"
when: "app.status.sync.status == 'Synced'"
send: [slack]
โ ConfigMap ์ ์ฉ:
kubectl apply -f argocd-notifications-cm.yaml
โ ํธ๋ฆฌ๊ฑฐ ์ค์ ํ์ธ:
argocd notifications trigger list
๐น Argo CD Notifications CLI ๋ช ๋ น์ด ์ ๋ฆฌ
๋ช ๋ น์ด | ์ค๋ช |
argocd notifications test-service slack | Slack ์๋ฆผ ํ ์คํธ |
argocd notifications test-service email | ์ด๋ฉ์ผ ์๋ฆผ ํ ์คํธ |
argocd notifications trigger list | ์ค์ ๋ ํธ๋ฆฌ๊ฑฐ ๋ชฉ๋ก ํ์ธ |
argocd notifications trigger enable <TRIGGER> | ํน์ ํธ๋ฆฌ๊ฑฐ ํ์ฑํ |
argocd notifications trigger disable <TRIGGER> | ํน์ ํธ๋ฆฌ๊ฑฐ ๋นํ์ฑํ |
๐น ๊ฒฐ๋ก : ์ด๋ฒ ๊ธ์์ ๋ฐฐ์ด ํต์ฌ ๋ด์ฉ ์ ๋ฆฌ
๐ข Argo CD Notifications๋ฅผ ํ์ฉํ๋ฉด ์ ํ๋ฆฌ์ผ์ด์
๋ฐฐํฌ ์ํ๋ฅผ ์ค์๊ฐ์ผ๋ก ๋ชจ๋ํฐ๋ง ๊ฐ๋ฅ
๐ข Slack, ์ด๋ฉ์ผ, Webhook์ ํตํด ๋ฐฐํฌ ์ฑ๊ณต/์คํจ ์๋ฆผ์ ๋ฐ์ ์ ์์
๐ข ConfigMap๊ณผ Secret์ ํ์ฉํ์ฌ ์ ์ฐํ ์๋ฆผ ์ค์ ์ด ๊ฐ๋ฅํจ
๐ข ์๋ํ๋ ์๋ฆผ ์์คํ
์ ๊ตฌ์ถํ์ฌ GitOps ํ๊ฒฝ์์ ๋น ๋ฅด๊ฒ ์ด์๋ฅผ ๊ฐ์งํ๊ณ ๋์ ๊ฐ๋ฅ