Notification slack

slack 설정

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

slack에서 add apps ==> app directory ==> build ==> create custom app

app directory
build
create custom app

create an app from scratch

create an app from scratch
create app

oauth & permission

bot token scope ==> add an oauth scope ==>

add an oauth scope

chat:write추가

chat:write:customize는 메세지를 커스터 마이즈하려면 추가

Install App to Workspace

allow

토큰이 생성이 되면 복사해둔다.

argocd 채널에 application추가

채널에서 Add apps >> channel detail >> integration >> argocd-notifications

Add apps
Add apps
Add apps

argocd에 설치하기

mkdir -p core/argocd-notifications
cd core/argocd-notifications
apiVersion: kustomize.config.k8s.io/v1beta1

kind: Kustomization

resources:
  - https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/v1.1.1/manifests/install.yaml

patches:
  - path: https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/v1.1.1/catalog/install.yaml
    target:
      kind: ConfigMap
      name: argocd-notifications-cm
  - path: slack-secret.yml
    target:
      kind: Secret
      name: argocd-notifications-secret

patchesStrategicMerge:
  - slack-configmap.yml

argocd에서 앱을 추가하자.

add-apps/argocd-notifications.yml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: argocd-notifications
spec:
  destination:
    name: ''
    namespace: argocd
    server: 'https://kubernetes.default.svc'
  source:
    path: apps/core/argocd-notifications
    repoURL: 'git@github.com:xxxxx/xxxx.git'
    targetRevision: HEAD
  project: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - CreateNamespace=true
kubectl apply -f add-apps/argocd-notifications.yml

subscribe trigger

Application

Application에 annotations 을 추가해주면된다.

kubectl edit application AAA -n argocd
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  # 여기만 추가
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my_channel

이러면 알림을 받을수 있다.

Project

Project 단위에 다 보내려면 프로젝트설정에 annotations 을 추가해주면 된다.

kubectl get AppProjects -n argocd
kubectl edit appProject default -n argocd
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  # 여기만 추가
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my-channel1;my-channel2

command line으로

trigger.yaml
metadata:
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.slack: argocd
kubectl patch AppProjects default -n argocd --patch "$(cat trigger.yaml)" --type=merge

Last updated

Was this helpful?