이 글에서는 AWS EKS 클러스터 환경에서 ArgoCD Notifications를 설정하고, 애플리케이션 동기화 성공/실패 시 Slack으로 알림을 보내는 방법을 다룹니다. 공식 ArgoCD Helm 차트(v8.3.1)를 기반으로 진행했으며, 실제 환경에서 발생한 문제와 해결 과정을 정리했습니다.
초기 문제 상황
ArgoCD Notifications를 Slack과 연동하면서 아래와 같은 문제를 겪었습니다.
- argocd-notifications-cm ConfigMap에서 서비스 설정 누락
- Slack 알림 전송 시 "not_authed" 에러 발생
- Terraform으로 리소스 정의 시 metadata 블록 누락으로 검증 오류 발생
- Notifications Controller에서 과도한 로그 출력
해결 과정
1. Terraform Validation 오류 수정
문제: CronJob 정의에서 metadata 블록이 없어 아래와 같은 에러 발생:
Too few blocks specified for "metadata"
해결: job_template와 template에 빈 metadata {} 블록을 추가하여 문제 해결.
job_template {
metadata {}
spec {
template {
metadata {}
spec {
# container spec...
}
}
}
}
2. 올바른 Notifications 구조 적용
Helm 차트(v8.3.1)는 특정 구조를 요구합니다.
처음에는 service.slack를 사용했지만 "not_authed" 에러가 발생했습니다.
정상 동작하는 설정:
notifications:
enabled: true
cm:
create: true
secret:
create: true
items:
slack-webhook: "${var.slack_webhook}"
notifiers:
service.webhook.slack: |
url: $slack-webhook
headers:
- name: Content-Type
value: application/json
3. Secret 참조 문제 해결
문제: Slack webhook secret이 잘못된 위치에 생성되어 "config referenced '$slack-webhook', but key does not exist in secret" 오류 발생.
해결: notifications.secret.items에 webhook을 정의하여 올바르게 참조되도록 수정.
4. Webhook 인증 문제 해결
Slack Webhook은 service.slack 대신 service.webhook.slack을 사용해야 정상 작동합니다.
실패 예시:
notifiers:
service.slack: |
webhook: $slack-webhook
성공 예시:
notifiers:
service.webhook.slack: |
url: $slack-webhook
headers:
- name: Content-Type
value: application/json
5. 로깅 및 성능 최적화
문제: Controller가 1분마다 로그를 출력하여 과도한 로그 발생.
해결 방법:
- 로그 레벨을 error로 낮춤
- 리소스 요청/제한 추가
configs:
params:
notificationscontroller.log.level: "error"
notifications:
controller:
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 200m
memory: 256Mi
※ 1분 주기 스캔은 ArgoCD 소스코드에 하드코딩되어 변경 불가.
최종 동작하는 설정 예시
notifications:
enabled: true
controller:
replicas: 1
env:
- name: ARGOCD_NOTIFICATIONS_CONTROLLER_SELF_SERVICE_NOTIFICATION_ENABLED
value: "false"
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 200m
memory: 256Mi
cm:
create: true
secret:
create: true
items:
slack-webhook: "${var.slack_webhook}"
notifiers:
service.webhook.slack: |
url: $slack-webhook
headers:
- name: Content-Type
value: application/json
templates:
template.app-sync-succeeded: |
webhook:
slack:
method: POST
body: |
{
"text": "✅ *{{.app.metadata.name}}* sync **SUCCEEDED**\n• Project: `{{.app.spec.project}}`\n• Revision: `{{.app.status.sync.revision}}`{{if .context.argocdUrl}}\n• Open: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}{{end}}"
}
triggers:
trigger.on-sync-succeeded: |
- when: app.status.operationState != nil
&& app.status.operationState.phase == 'Succeeded'
&& app.status.sync.status == 'Synced'
oncePer: app.status.operationState.syncResult.revision
send: [app-sync-succeeded]
subscriptions:
- recipients:
- slack
triggers:
- on-sync-succeeded
핵심 정리 (Key Learnings)
- Slack Webhook은 반드시 service.webhook.slack 사용
- Secret은 notifications.secret.items에 정의해야 정상 참조
- 로그 레벨은 configs.params.notificationscontroller.log.level로 조절 가능
- 1분 주기 스캔은 고정값 (변경 불가)
- 설정 변경 시 Notifications Controller를 반드시 재시작해야 반영
트러블슈팅 팁
- "not_authed" 에러 → Webhook URL 확인 및 service.webhook.slack 사용
- Secret 관련 에러 → notifications.secret 확인
- 설정 반영 안 됨 → Controller 재시작 필요
- 로그 과다 발생 → 로그 레벨을 warn 또는 error로 변경
'DevOps' 카테고리의 다른 글
| Terraform에서 AWS SSM Parameter Store 활용하기 (0) | 2025.09.04 |
|---|---|
| ArgoCD Slack Notifications : Webhook vs Token 방식 비교 (1) | 2025.09.01 |
| ArgoCD 배포 시 실패한 Pod는 삭제됐는데 ReplicaSet은 남아있다? 괜찮은 걸까? (1) | 2025.08.29 |
| Argo CD CLI login 트러블슈팅 (ALB/Ingress, gRPC-Web, Windows) (0) | 2025.08.29 |
| Argo CD에서 “읽기 전용(READ-ONLY)” 사용자 만들기 (Helm/Terraform 예시) (0) | 2025.08.29 |
댓글