반응형
슬랙 세팅
https://api.slack.com/apps?new_app=1
설정후 상단의 Install to Workspace
슬랙을 보낼 채널에 App을 추가 해준다.
ArgoCD notification 배포
https://argocd-notifications.readthedocs.io/en/stable/
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/release-1.0/manifests/install.yaml
Install Argo CD Notifications
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj-labs/argocd-notifications/release-1.0/catalog/install.yaml
Install Triggers and Templates from the catalog
export SLACK_TOKEN=<slack-token>
kubectl apply -n argocd -f - << EOF
apiVersion: v1
kind: Secret
metadata:
name: argocd-notifications-secret
stringData:
slack-token: $SLACK_TOKEN
EOF
Add token to argocd-notifications-secret secret
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.slack: |
apiURL: <url> # optional URL, e.g. https://example.com/api
token: $slack-token
username: <override-username> # optional username
icon: <override-icon> # optional icon for the message (supports both emoij and url notation)
kubectl patch app $APP_NAME -n $NAMESPACE -p '{"metadata": {"annotations": {"notifications.argoproj.io/subscribe.on-sync-succeeded.slack":"$SLACK_CHANNEL_NAME"}}}' --type merge
위와 같이 명령어를 통해 수정하거나
kubectl edit app $APP_NAME -n $NAMESPACE
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
notifications.argoproj.io/subscribe.on-sync-succeeded.slack: $SALCK_CHANNEL_NAME
notifications.argoproj.io/subscribe.on-sync-status-unknown.slack: $SALCK_CHANNEL_NAME
notifications.argoproj.io/subscribe.on-sync-running.slack: $SALCK_CHANNEL_NAME
notifications.argoproj.io/subscribe.on-sync-failed.slack: $SALCK_CHANNEL_NAME
notifications.argoproj.io/subscribe.on-health-degraded.slack: $SALCK_CHANNEL_NAME
notifications.argoproj.io/subscribe.on-deployed.slack: $SALCK_CHANNEL_NAME
notifications.argoproj.io/subscribe.on-deleted.slack: $SALCK_CHANNEL_NAME
notifications.argoproj.io/subscribe.on-created.slack: $SALCK_CHANNEL_NAME
위와 같이 직접 어노테이션을 수정하여 반영 하도록 한다.
https://github.com/argoproj/argo-cd/blob/master/notifications_catalog/install.yaml
trigger.on-created: |
- description: Application is created.
oncePer: app.metadata.name
send:
- app-created
when: "true"
trigger.on-deleted: |
- description: Application is deleted.
oncePer: app.metadata.name
send:
- app-deleted
when: app.metadata.deletionTimestamp != nil
trigger.on-deployed: |
- description: Application is synced and healthy. Triggered once per commit.
oncePer: app.status.operationState.syncResult.revision
send:
- app-deployed
when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status
== 'Healthy'
trigger.on-health-degraded: |
- description: Application has degraded
send:
- app-health-degraded
when: app.status.health.status == 'Degraded'
trigger.on-sync-failed: |
- description: Application syncing has failed
send:
- app-sync-failed
when: app.status.operationState.phase in ['Error', 'Failed']
trigger.on-sync-running: |
- description: Application is being synced
send:
- app-sync-running
when: app.status.operationState.phase in ['Running']
trigger.on-sync-status-unknown: |
- description: Application status is 'Unknown'
send:
- app-sync-status-unknown
when: app.status.sync.status == 'Unknown'
trigger.on-sync-succeeded: |
- description: Application syncing has succeeded
send:
- app-sync-succeeded
when: app.status.operationState.phase in ['Succeeded']
트리거는 위와같이 정의 되어 있어 필요한 상황에 따라 적용하도록 한다.
https://argocd-notifications.readthedocs.io/en/stable/services/slack/
Slack - Argo CD Notifications
Slack Configuration Create Slack Application using https://api.slack.com/apps?new_app=1 Once application is created navigate to Enter OAuth & Permissions Click Permissions under Add features and functionality section and add chat:write:bot scope. To use th
argocd-notifications.readthedocs.io
반응형