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

Argo CD Dex를 사용한 인증

원문 보기 위키 갱신

Argo Workflows Server가 인증을 Argo CD에 내장된 Dex에 위임하는 구성 방법을 다룹니다. SAML 기반 Okta처럼 Argo Workflows와 직접 통합할 수 없는 IdP를 쓸 때 유용하며, Kustomize와 Helm 차트 예제를 함께 제공합니다.

출처: Argo Workflows 문서

본문

Argo Workflows Server가 인증에 Argo CD의 Dex 인스턴스를 사용하도록 구성할 수 있습니다. 예컨대 Argo Workflows와 직접 통합할 수 없는 SAML 기반 Okta를 사용하는 경우가 그렇습니다. 이렇게 만들려면 다음이 필요합니다:

  • 최소한 Dex v2.35.0 이상을 사용해야 합니다. staticClients[].secretEnv가 이 버전에서 추가되었기 때문입니다. 즉 Argo CD 1.7.12 이상이라는 뜻입니다.

  • Dex와 Argo Workflows Server 양쪽에서 쓸 client-id와 client-secret 두 키를 담은 시크릿. 이 예제에서 client-id는 argo-workflows-sso이며, client-secret은 아무 랜덤 문자열이면 됩니다. Argo CD와 Argo Workflows가 서로 다른 네임스페이스에 설치되어 있다면 이 시크릿은 양쪽 네임스페이스 모두에 존재해야 합니다. 예:

    apiVersion: v1
    kind: Secret
    metadata:
      name: argo-workflows-sso
    data:
      # client-id is 'argo-workflows-sso'
      client-id: YXJnby13b3JrZmxvd3Mtc3Nv
      # client-secret is 'MY-SECRET-STRING-CAN-BE-UUID'
      client-secret: TVktU0VDUkVULVNUUklORy1DQU4tQkUtVVVJRA==
    
  • --auth-mode=sso 서버 인자 추가

  • argo-workflows-sso에 맞춰 구성된 Dex staticClients

  • Argo Workflows Server의 sso 설정을 맞춰 채워 넣기

Argo CD의 Dex로 인증하기 위한 매니페스트 예제 (Kustomize)

Argo CD에서 Dex 디플로이먼트와 설정에 환경 변수를 추가합니다:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: argocd-dex-server
spec:
  template:
    spec:
      containers:
        - name: dex
          env:
            - name: ARGO_WORKFLOWS_SSO_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: argo-workflows-sso
                  key: client-secret
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-cm
data:
  # Kustomize sees the value of dex.config as a single string instead of yaml. It will not merge
  # Dex settings, but instead it will replace the entire configuration with the settings below,
  # so add these to the existing config instead of setting them in a separate file
  dex.config: |
    # Setting staticClients allows Argo Workflows to use Argo CD's Dex installation for authentication
    staticClients:
      # This is the OIDC client ID in plaintext
      - id: argo-workflows-sso
        name: Argo Workflow
        redirectURIs:
          - https://argo-workflows.mydomain.com/oauth2/callback
        secretEnv: ARGO_WORKFLOWS_SSO_CLIENT_SECRET

staticClients의 id 필드는 client-id와 일치해야 한다는 점에 유의하세요.

Argo Workflows에서는 argo-server 디플로이먼트에 --auth-mode=sso 인자를 추가합니다.

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: argo-server
spec:
  template:
    spec:
      containers:
        - name: argo-server
          args:
            - server
            - --auth-mode=sso
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: workflow-controller-configmap
data:
  # SSO Configuration for the Argo server.
  # You must also start argo server with `--auth-mode sso`.
  # https://argo-workflows.readthedocs.io/en/latest/argo-server-auth-mode/
  sso: |
    # This is the root URL of the OIDC provider (required).
    issuer: https://argo-cd.mydomain.com/api/dex
    # This is name of the secret and the key in it that contain OIDC client
    # ID issued to the application by the provider (required).
    clientId:
      name: argo-workflows-sso
      key: client-id
    # This is name of the secret and the key in it that contain OIDC client
    # secret issued to the application by the provider (required).
    clientSecret:
      name: argo-workflows-sso
      key: client-secret
    # This is the redirect URL supplied to the provider (required). It must
    # be in the form <argo-server-root-url>/oauth2/callback. It must be
    # browser-accessible.
    redirectUrl: https://argo-workflows.mydomain.com/oauth2/callback

Argo CD의 Dex로 인증하기 위한 Helm 차트 설정 예제

argo-cd/values.yaml:

     dex:
       image:
         tag: v2.35.0
       env:
         - name: ARGO_WORKFLOWS_SSO_CLIENT_SECRET
           valueFrom:
             secretKeyRef:
               name: argo-workflows-sso
               key: client-secret
     server:
       config:
         dex.config: |
           staticClients:
           # This is the OIDC client ID in plaintext
           - id: argo-workflows-sso
             name: Argo Workflow
             redirectURIs:
               - https://argo-workflows.mydomain.com/oauth2/callback
             secretEnv: ARGO_WORKFLOWS_SSO_CLIENT_SECRET

argo-workflows/values.yaml:

     server:
       # Chart version 0.39.0 and after
       authModes:
         - sso
       sso:
         enabled: true
         issuer: https://argo-cd.mydomain.com/api/dex
         # sessionExpiry defines how long your login is valid for in hours. (optional, default: 10h)
         sessionExpiry: 240h
         clientId:
           name: argo-workflows-sso
           key: client-id
         clientSecret:
           name: argo-workflows-sso
           key: client-secret
         redirectUrl: https://argo-workflows.mydomain.com/oauth2/callback

더 알아보기 (Learn more)

  • Dex는 staticClients[].secretEnv를 지원하는 v2.35.0 이상이 필요하며, 이는 곧 Argo CD 1.7.12 이상을 의미합니다.
  • 시크릿은 client-id와 client-secret 두 키를 담아야 하고, 두 제품이 다른 네임스페이스에 있으면 양쪽에 모두 만들어야 합니다.
  • Kustomize는 dex.config를 YAML이 아니라 단일 문자열로 취급하므로 설정을 병합하지 않고 통째로 교체합니다. 기존 설정에 덧붙이는 방식으로 관리하세요.