๐Ÿ’ฌ ArgoCD์˜ ์ƒํƒœ๋ฅผ Slack์— ๋ฉ”์‹œ์ง€ ๋ณด๋‚ด๊ธฐ

2023๋…„ 4์›” 15์ผ

head

๋“ค์–ด๊ฐ€๋ฉฐ

์‚ฌ๋‚ด์—์„œ ๋ฐฐํฌ ์ž๋™ํ™”๋กœ ArgoCD๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์—ฌ๋Ÿฌ ๊ฐœ๋ฐœ์ž๊ฐ€ Sync๋ฅผ ๋งž์ถ”๋Š” ์ž‘์—…์„ ํ• ๋•Œ์— ๋™์‹œ์— ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜๋„ ์žˆ๋Š” ์šฐ๋ ค๊ฐ€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ๋ˆ„๊ตฐ๊ฐ€ Sync๋ฅผ ๋งž์ถ”๋Š” ์ž‘์—…์„ ํ• ๋•Œ๋‚˜ ์™„๋ฃŒ๋˜์—ˆ์„๋•Œ, ์‹คํŒจํ•˜์˜€์„๋•Œ, ํŒŒ๋“œ๊ฐ€ ์ฃฝ์—ˆ์„ ๋•Œ ์Šฌ๋ž™์„ ํ†ตํ•ด ์•Œ๋ฆผ์„ ๋ณด๋‚ด๋Š” ์„ค์ •์„ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

How To Setting

Slack

1

๋จผ์ € Slack์—์„œ ์ƒˆ๋กœ์šด ์•ฑ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

Create an App > From scratch ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

2

์ƒ์„ฑํ•œ ํ›„ ์™ผ์ชฝ ๋ฉ”๋‰ด์˜ OAuth & Permissions ๋ฉ”๋‰ด์— ์ ‘๊ทผํ•ฉ๋‹ˆ๋‹ค.

3

Scopes > Bot Token Scopes์—์„œ chat:writ ๊ธฐ๋Šฅ์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ ํ›„ ์ƒ๋‹จ์œผ๋กœ ์ด๋™ํ•˜์—ฌ Install To Workspace ์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

4

๊ทธ๋Ÿฌ๋ฉด ์œ„์™€ ๊ฐ™์ด Bot User OAuth Token ์ด ๋ฐœ๊ธ‰๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

5

๊ทธ ํ›„ ์Šฌ๋ž™์—์„œ ํ•ด๋‹น ์•ฑ์„ ์ถ”๊ฐ€ํ•ด์ค๋‹ˆ๋‹ค.

ArgoCD

[ ] ์œผ๋กœ ๋˜์–ด์žˆ๋Š” ์นธ์€ ์ง์ ‘ ์ž…๋ ฅํ•ด์•ผํ•˜๋Š” ๊ฐ’์ž…๋‹ˆ๋‹ค.

$ kubectl apply -f https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/release-1.0/manifests/install.yaml -n [argoCD namespace]
$ kubectl apply -f https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/release-1.0/catalog/install.yaml -n [argoCD namespace]

์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ ์‹œ์ผœ ArgoCD Notification์˜ manifests ํŒŒ์ผ๊ณผ catalog ํŒŒ์ผ์„ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

argocd-notifications-secret

apiVersion: v1 
kind: Secret 
metadata: 
  name: argocd-notifications-secret 
stringData:
  slack-token: [Bot User OAuth Token]

argocd-nofitications-cm

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
  namespace: argocd
data:
  service.slack: |
    token: $slack-token
$ kubectl edit cm argocd-notifications-cm -n ${argocd_namespace}

์œ„์˜ ๋ช…๋ น์–ด ์‹คํ–‰ ํ›„

apiVersion: v1
  kind: ConfigMap
  metadata:
    name: argocd-notifications-cm
    namespace: argocd
  data:
    service.slack: |
      token: [Bot User OAuth Token]<- ์ด ๋ถ€๋ถ„ ์ž‘์„ฑ

argocd-notification check

ArgoCD Configmap์—์„œ notificatoin์ด ์„ค์ •๋˜์–ด์žˆ๋Š”์ง€ ์ฒดํฌํ•˜๊ธฐ ์œ„ํ•ด ArgoCD๊ฐ€ ๋ฐฐํฌ๋˜์–ด์žˆ๋Š” namespace๋กœ ์ด๋™ํ•˜์—ฌ ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

$ kubectl edit cm

6

์œ„์˜ ์ด๋ฏธ์ง€์ฒ˜๋Ÿผ argocd-notifications-cm ๊ฐ€ ๋“ฑ๋ก๋˜์–ด์žˆ๋‹ค๋ฉด ์ž˜ ์„ค์ •๋˜์–ด ์žˆ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค!

๊ทธ ํ›„ ArgoCD๊ฐ€ ํŠน์ •ํ•œ ์•ก์…˜์„ ํ•  ์‹œ์— ์•Œ๋ฆผ์„ ๋ฐ›๊ธฐ ์œ„ํ•ด ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด์ค๋‹ˆ๋‹ค.

$ kubectl patch app [app name] -n [argoCD Namespace] -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-succeeded.slack":"[slack chanel name"}}}' --type merge

ArgoCD Notification List

Sync๊ฐ€ ์„ฑ๊ณตํ–ˆ์„ ๋•Œ ์•Œ๋ฆผ
notifications.argoproj.io/subscribe.on-sync-succeeded.slack
Sync๊ฐ€ ์‹คํŒจํ–ˆ์„ ๋•Œ ์•Œ๋ฆผ
notifications.argoproj.io/subscribe.on-sync-failed.slack
Sync๊ฐ€ ์ง„ํ–‰์ค‘์ผ ๋•Œ ์•Œ๋ฆผ
notifications.argoproj.io/subscribe.on-sync-running.slack
Sync ์ƒํƒœ๊ฐ€ Unknown์ผ ๋•Œ ์•Œ๋ฆผ
notifications.argoproj.io/subscribe.on-sync-status-unknown.slack
Health๊ฐ€ Degrade ๋˜์—ˆ์„ ๋•Œ ์•Œ๋ฆผ
notifications.argoproj.io/subscribe.on-health-degraded.slack
Deploy ๋˜์—ˆ์„ ๋•Œ ์•Œ๋ฆผ
notifications.argoproj.io/subscribe.on-deployed.slack

Finish

7

์œ„์˜ ์„ค์ •์„ ๋ชจ๋‘ ์™„๋ฃŒํ•˜๋ฉด ์ •์ƒ์ ์œผ๋กœ Slack ์ฑ„๋„์„ ํ†ตํ•ด noti๊ฐ€ ์˜ค๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!