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

ECR 인증 토큰 생성기 (ECRAuthorizationToken)

원문 보기 위키 갱신

ECRAuthorizationToken spec은 GetAuthorizationToken API를 사용해서 인증 토큰을 가져와요. 이 인증 토큰은 12시간 동안 유효해요. 자세한 내용은 Amazon Elastic Container Registry User Guide의 registry authentication 문서를 참고하세요.

출처: External Secrets

본문

출력 키와 값

Key Description
username docker login 명령에 쓸 username.
password docker login 명령에 쓸 password.
proxy_endpoint docker login 명령에서 이 인증 토큰에 사용할 레지스트리 URL.
expires_at 토큰이 만료되는 시간(UNIX time, 1970년 1월 1일 UTC 이후 초).

인증 (Authentication)

다음 세 가지 인증 메커니즘 중에서 선택할 수 있어요:

  • spec.auth.secretRef로 정적(static) 자격 증명 사용
  • spec.auth.jwt로 IRSA Service Account 지정
  • 컨트롤러 환경에서 SDK default credentials chain의 자격 증명 사용

예시 매니페스트

apiVersion: generators.external-secrets.io/v1alpha1
kind: ECRAuthorizationToken
metadata:
  name: ecr-gen
spec:

  # specify aws region (mandatory)
  region: eu-west-1

  # assume role with the given authentication credentials
  role: "my-role"

  # choose an authentication strategy
  # if no auth strategy is defined it falls back to using
  # credentials from the environment of the controller.
  auth:

    # 1: static credentials
    # point to a secret that contains static credentials
    # like AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
    secretRef:
      accessKeyIDSecretRef:
        name: "my-aws-creds"
        key: "key-id"
      secretAccessKeySecretRef:
        name: "my-aws-creds"
        key: "access-secret"

    # option 2: IAM Roles for Service Accounts
    # point to a service account that should be used
    # that is configured for IAM Roles for Service Accounts (IRSA)
    jwt:
      serviceAccountRef:
        name: "oci-token-sync"

위 ECR generator를 참조하는 ExternalSecret 예시:

apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
  name: "ecr-secret"
spec:
  refreshInterval: "1h0m0s"
  target:
    name: ecr-secret
    template:
      type: kubernetes.io/dockerconfigjson
      metadata:
        annotations:
          expiresAt: "{{ .expires_at }}"
      data:
        .dockerconfigjson: |
          {
            "auths": {
              "{{ .proxy_endpoint | replace "https://" "" }}": {
                "username": "{{ .username }}",
                "password": "{{ .password }}",
                "auth": "{{ printf "%s:%s" .username .password | b64enc }}"
              }
            }
          }
  dataFrom:
    - sourceRef:
        generatorRef:
          apiVersion: generators.external-secrets.io/v1alpha1
          kind: ECRAuthorizationToken
          name: "ecr-gen"

더 알아보기 (Learn more)