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?