[ArgoCD] 슬랙 설정하기

1. Argo CD Notifications 와 Triggers and Templates from the catalog 를 설치한다. 설치할 때 namespace는 argocd로 한다.

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

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

 

2. 슬랙으로 접속해 새 앱을 생성한다

- https://api.slack.com/apps?new_app=1 

etc-image-0

3. From scratch를 선택한다

etc-image-1

4. 앱의 이름과 workspace를 지정한다. app name: argoCD, workspace는 본인의 워크스페이스를 지정한다. 

etc-image-2

5. Oauth & Permissions를 선택한다

etc-image-3

6. Scopes - chat:write를 선택한다 

etc-image-4

7. install app to workspace를 누른다

etc-image-5
etc-image-6

8. 생성된 토큰은 잘 복사해둔다

etc-image-7

9. 새 채널을 생성한다

etc-image-8

10. argo-test 채널로 클릭하여 해당 채널로 이동한다. 화면의 오른쪽 상단에 보이는 버튼을 누르면 다음과 같은 창이 뜬다

etc-image-9

11. 앱 추가를 누른다. argocd 앱을 추가한다. 

etc-image-10

 

지금까지 슬랙에 대한 알림이 설정이 완료 되었다.

 

ArgoCD 설정하기

1. kubectl apply -f argocd-notifications-secret.yaml -n argocd

- 슬랙에서 받은 토큰을 넣는다

apiVersion: v1
  kind: Secret
  metadata:
      name: argocd-notifications-secret
  stringData:
      slack-token: <Oauth-access-token>

2. kubectl edit cm argocd-notifications-cm -n argocd

apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
  service.slack: |
    token: $slack-token

 

 

ArgoCD 공식문서에서 본대로 실행하는 과정에서 다음 에러가 발생하였다. 리소스가 없기 때문이다. 처음에는 왜 이러한 에러가 발생하는지 몰랐다. 하지만 ArgoCD는 커스텀 리소스으로 App 배포한다. 하지만 나는 새로운 app를 생성하려고 하였으나 CRD spec를 정확히 작성하지 않아 발생하였던 문제이다. 다음 과정에서 APP을 생성하고 생성한 APP을 수정하면 다음 에러를 마주치지 않는다.

error: error when retrieving current configuration of:
Resource: "argoproj.io/v1alpha1, Resource=applications", GroupVersionKind: "argoproj.io/v1alpha1, Kind=Application"
Name: "", Namespace: "argocd"
from server for: "slact-subscription.yaml": resource name may not be empty

3. argocd 홈페이지에서 APP 생성한다

etc-image-11
etc-image-12

4. kubectl get app -n argocd # 현재 실행중인 argocd app을 보여준다

kubectl patch app 앱이름 -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-running.slack":”알림을 보낼 채널명"}}}' --type merge

kubectl patch app 앱이름 -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-succeeded.slack":"알림을 보낼 채널명"}}}' --type merge

kubectl patch app 앱이름 -n argocd -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-failed.slack":"알림을 보낼 채널명"}}}' --type merge

 

참조 : 

https://argo-cd.readthedocs.io/en/stable/operator-manual/notifications/services/slack/

https://argocd-notifications.readthedocs.io/en/stable/

https://argocd-notifications.readthedocs.io/en/stable/services/slack/

https://huntedhappy.github.io/argo/

https://wookiist.dev/154

'CI&CD' 카테고리의 다른 글

[Github Actions] 다수의 설정 한번에 주입  (0) 2024.06.08
[ArgoCD] 설치하기  (0) 2023.08.14
[ArgoCD] github 연동하기  (0) 2023.08.14
[Jenkins] 슬랙 알람  (0) 2023.08.14
[Jenkins] gtihub webhook 구성하기  (0) 2023.08.14