본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

알림 서비스: GitHub

원문 보기 위키 갱신

Argo Rollouts의 알림(Notifications) 기능은 롤아웃 이벤트를 외부 서비스로 전달합니다. 이 문서에서는 GitHub 알림 서비스가 GitHub Apps를 이용해 커밋 상태(commit status)를 변경하는 방식의 파라미터, 설정 방법, 템플릿을 설명해 드립니다.

출처: Argo Rollouts 문서

본문

GitHub 알림 서비스는 GitHub Apps를 사용하여 커밋 상태를 변경하며, 다음 설정을 지정해야 합니다.

  • appID - 앱 id
  • installationID - 앱 설치 id
  • privateKey - 앱 개인 키
  • enterpriseBaseURL - 선택 사항 URL, 예: https://git.example.com/api/v3
  • maxIdleConns - 선택 사항, 모든 호스트에 걸친 유휴(keep-alive) 연결의 최대 개수.
  • maxIdleConnsPerHost - 선택 사항, 호스트당 유휴(keep-alive) 연결의 최대 개수.
  • maxConnsPerHost - 선택 사항, 호스트당 총 연결의 최대 개수.
  • idleConnTimeout - 선택 사항, 유휴(keep-alive) 연결이 닫히기 전에 열린 상태로 유지되는 최대 시간.

⚠️ NOTE: argoproj/notifications-engine#205이 해결될 때까지 enterpriseBaseURL에 /api/v3를 지정하는 것이 필요합니다.

구성 (Configuration)

  1. https://github.com/settings/apps/new를 사용하여 GitHub App을 생성합니다.
  2. 저장소 권한을 변경하여 commit statuses 및/또는 deployments 및/또는 pull requests comments 쓰기를 활성화합니다. 2
  3. 개인 키(private key)를 생성하고 자동으로 다운로드합니다. 3
  4. 앱을 계정에 설치(install)합니다.
  5. privateKey를 argo-rollouts-notification-secret Secret에 저장하고, argo-rollouts-notification-configmap ConfigMap에서 GitHub 통합을 구성합니다.
apiVersion: v1
kind: ConfigMap
metadata:
  name: argo-rollouts-notification-configmap
data:
  service.github: |
    appID: <app-id>
    installationID: <installation-id>
    privateKey: $github-privateKey
apiVersion: v1
kind: Secret
metadata:
  name: <secret-name>
stringData:
  github-privateKey: |
    [REDACTED PRIVATE KEY]
  1. GitHub 통합에 대한 구독(subscription)을 생성합니다.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    notifications.argoproj.io/subscribe.<trigger-name>.github: ""

템플릿 (Templates)

template.app-deployed: |
  message: |
    Application {{.app.metadata.name}} is now running new version of deployments manifests.
  github:
    repoURLPath: "{{.app.spec.source.repoURL}}"
    revisionPath: "{{.app.status.operationState.syncResult.revision}}"
    status:
      state: success
      label: "continuous-delivery/{{.app.metadata.name}}"
      targetURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
    deployment:
      state: success
      environment: production
      environmentURL: "https://{{.app.metadata.name}}.example.com"
      logURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
      requiredContexts: []
      autoMerge: true
      transientEnvironment: false
      reference: v1.0.0
    pullRequestComment:
      content: |
        Application {{.app.metadata.name}} is now running new version of deployments manifests.
        See more here: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true
      commentTag: "continuous-delivery/{{.app.metadata.name}}"
    checkRun:
      name: "continuous-delivery/{{.app.metadata.name}}"
      details_url: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
      status: completed
      conclusion: success
      started_at: "YYYY-MM-DDTHH:MM:SSZ"
      completed_at: "YYYY-MM-DDTHH:MM:SSZ"
      output:
        title: "Deployment of {{.app.metadata.name}} on ArgoCD"
        summary: "Application {{.app.metadata.name}} is now running new version of deployments manifests."
        text: |
          Application {{.app.metadata.name}} is now running new version of deployments manifests.
          See more here: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true

Notes (참고 사항):

  • message가 140자 이상이면 잘림(truncate)됩니다.
  • github.repoURLPath와 github.revisionPath가 위와 같다면 생략할 수 있습니다.
  • Automerge는 선택 사항이며 github deployments의 경우 기본값이 true로, 요청된 ref가 기본 브랜치와 최신 상태를 유지하도록 보장합니다. 기본 브랜치에서 더 오래된 ref를 배포하려면 이 옵션을 false로 설정해야 합니다. 자세한 내용은 GitHub Deployment API Docs를 참고하세요.
  • github.pullRequestComment.content가 65536자 이상이면 잘립니다.
  • github.pullRequestComment.commentTag 파라미터는 주석을 식별하는 데 사용됩니다. 지정된 태그가 있는 주석이 발견되면 업데이트(upsert)되고, 태그가 있는 주석이 없으면 새 주석이 생성됩니다.
  • Reference는 선택 사항입니다. 설정하면 배포할 ref로 사용됩니다. 설정하지 않으면 revision이 배포할 ref로 사용됩니다.

커밋 상태 (Commit Statuses)

커밋 상태 생성 방법은 동일한 commit SHA와 context를 사용해 최대 1000회까지 시도할 수 있습니다. 이 한도에 도달하면 API가 검증 오류(HTTP 422)를 반환합니다. 알림 엔진은 이러한 오류를 무시하고 알림 시도를 완료된 것으로 표시합니다.

더 알아보기 (Learn more)

  • Argo Rollouts 알림 기능과 트리거(trigger) 개념 이해하기
  • PagerDuty 알림 서비스 설정 방법 알아보기
  • ConfigMap과 Secret을 활용한 알림 서비스 구성 원리 익히기
  • Commit status / Deployment API를 통한 CI/CD 연동 방식 살펴보기