Google Chat

Google Chat

이 알림 서비스는 Google Chat 웹훅으로 메시지 알림을 보내요. 웹훅 URL을 등록·저장하고, 구독 어노테이션에서 스페이스(space)를 지정하면 간단한 텍스트 메시지나 카드 메시지를 그 스페이스로 보낼 수 있어요. 스레드 키를 지정해 채팅 스레드 안으로 보낼 수도 있어요.

출처: 문서

본문

파라미터 (Parameters)

Google Chat 알림 서비스는 google chat 웹훅으로 메시지 알림을 보내요. 이 서비스는 다음 설정을 사용해요.

  • webhookswebhookName: webhookUrl 형태의 맵

설정 (Configuration)

  1. Google chat을 열고 메시지를 보내려는 스페이스로 이동해요.
  2. 페이지 상단 메뉴에서 Configure Webhooks를 선택해요.
  3. Incoming Webhooks 아래에서 Add Webhook을 클릭해요.
  4. 웹훅에 이름을 짓고, 선택적으로 이미지를 추가한 뒤 Save를 클릭해요.
  5. 웹훅 옆의 URL을 복사해요.
  6. URL을 argocd-notification-secret에 저장하고 argocd-notifications-cm에 선언해요.
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-notifications-cm
data:
  service.googlechat: |
    webhooks:
      spaceName: $space-webhook-url
apiVersion: v1
kind: Secret
metadata:
  name: <secret-name>
stringData:
  space-webhook-url: https://chat.googleapis.com/v1/spaces/<space_id>/messages?key=<key>&token=<token>
  1. 스페이스를 위한 구독(subscription)을 생성해요.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    notifications.argoproj.io/subscribe.on-sync-succeeded.googlechat: spaceName

템플릿 (Templates)

Google Chat 스페이스에 간단한 텍스트카드 메시지를 보낼 수 있어요. 간단한 텍스트 메시지 템플릿은 다음과 같이 정의할 수 있어요.

template.app-sync-succeeded: |
  message: The app {{ .app.metadata.name }} has successfully synced!

카드 메시지는 다음과 같이 정의할 수 있어요.

template.app-sync-succeeded: |
  googlechat:
    cardsV2: |
      - header:
          title: ArgoCD Bot Notification
        sections:
          - widgets:
              - decoratedText:
                  text: The app {{ .app.metadata.name }} has successfully synced!
          - widgets:
              - decoratedText:
                  topLabel: Repository
                  text: {{ call .repo.RepoURLToHTTPS .app.spec.source.repoURL }}
              - decoratedText:
                  topLabel: Revision
                  text: {{ .app.spec.source.targetRevision }}
              - decoratedText:
                  topLabel: Author
                  text: {{ (call .repo.GetCommitMetadata .app.status.sync.revision).Author }}

모든 Card 필드가 지원되며 알림에 사용할 수 있어요. 예전(현재 deprecated) cards 키로 레거시 카드 필드를 사용하는 것도 가능하지만, Google이 이 필드를 deprecated로 지정하고 더 새로운 cardsV2를 권장하므로 추천하지 않아요.

카드 메시지는 JSON으로도 작성할 수 있어요.

채팅 스레드 (Chat Threads)

스레드에 고유 키를 지정하면 채팅 스레드 안으로 간단한 텍스트와 카드 메시지를 모두 보낼 수 있어요. 스레드 키는 다음과 같이 정의할 수 있어요.

template.app-sync-succeeded: |
  message: The app {{ .app.metadata.name }} has successfully synced!
  googlechat:
    threadKey: {{ .app.metadata.name }}

더 알아보기 (Learn more)

  • 구독 — Google Chat 스페이스에 알림 연결.
  • 템플릿 — 텍스트·카드 메시지 작성법.