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

아티팩트 저장소(Artifact Repository) 설정하기

원문 보기 위키 갱신

아티팩트를 사용하는 Argo 워크플로우를 실행하려면 아티팩트 저장소(artifact repository)를 설정하고 사용해야 해요. S3 호환 저장소, GCS, Azure Blob, OSS 등 어떤 걸 쓰느냐에 따라 설정 방법이 달라지니, 이 문서를 따라 하나씩 확인해 보세요.

출처: Argo Workflows 문서

본문

아티팩트를 사용하는 Argo 워크플로우를 실행하려면, 아티팩트 저장소(artifact repository)를 설정하고 사용해야 해요. Argo는 AWS, GCS, MinIO 같은 S3 호환 아티팩트 저장소라면 무엇이든 지원해요. 이 섹션에서는 아티팩트 저장소를 설정하는 방법을 보여 주고, 이후 섹션에서 사용하는 방법을 다룰게요.

이름 입력 출력 가비지 컬렉션
Artifactory 예 예 아니요
Azure Blob 예 예 예
GCS 예 예 예
Git 예 아니요 아니요
HDFS 예 예 아니요
HTTP 예 예 아니요
OSS 예 예 예
Plugin 예 예 가능
Raw 예 아니요 아니요
S3 예 예 예

워크플로우에서 실제로 사용할 저장소는 다음 규칙으로 선택돼요:

  1. Artifact Repository Ref로 명시적으로 설정한 것. 이것이 가장 유연하고 안전하며 보안상 좋은 선택이에요.
  2. 워크플로우의 네임스페이스에 workflows.argoproj.io/default-artifact-repository 어노테이션을 가진 artifact-repositories라는 이름의 config map이 있으면 거기서 가져와요.
  3. 워크플로우 컨트롤러 config-map에서 가져와요.

보안

워크플로우에 제공하는 크리덴셜이, 사용자가 접근하게 하고 싶은 아티팩트에만 접근할 수 있도록 제한하는지 꼭 확인하세요.

Argo-workflows는 "key에 ../가 들어 있으면 사용자가 '디렉터리 구조'를 거슬러 올라갈 수 있는" 경로 순회(path traversal)를 명시적으로 허용해요.

버려진 업로드 정리 (Abandoned Upload Cleanup)

⚠️ UI에서 입력 아티팩트를 업로드할 때는, 워크플로우가 제출되기 전에 업로드된 파일이 아티팩트 저장소의 uploads/{namespace}/{uuid}/{filename}에 기록돼요. 워크플로우가 끝내 제출되지 않으면 (사용자가 화면을 벗어나거나 브라우저 탭을 닫은 경우), 그 오브젝트는 어떤 워크플로우의 라이프사이클에도 묶이지 않고 자동으로 삭제되지 않아요.

운영자는 버려진 업로드를 되돌려 받기 위해 아티팩트 버킷의 uploads/ 프리픽스에 라이프사이클/TTL 규칙을 설정해야 해요.

S3:

{
  "Rules": [
    {
      "ID": "expire-abandoned-uploads",
      "Filter": { "Prefix": "uploads/" },
      "Status": "Enabled",
      "Expiration": { "Days": 7 }
    }
  ]
}
aws s3api put-bucket-lifecycle-configuration \
  --bucket my-artifact-bucket \
  --lifecycle-configuration file://lifecycle.json

GCS:

{
  "rule": [
    {
      "action": { "type": "Delete" },
      "condition": { "age": 7, "matchesPrefix": ["uploads/"] }
    }
  ]
}
gcloud storage buckets update gs://my-artifact-bucket \
  --lifecycle-file=lifecycle.json

OSS (Alibaba Cloud):

{
  "Rule": [
    {
      "ID": "expire-abandoned-uploads",
      "Prefix": "uploads/",
      "Status": "Enabled",
      "Expiration": { "Days": 7 }
    }
  ]
}
aliyun oss lifecycle --method put oss://my-artifact-bucket lifecycle.json

MinIO 설정하기

MinIO는 Helm으로 클러스터에 설치할 수 있어요.

먼저 helm을 설치하세요. 그다음 아래 명령으로 MinIO를 설치해요:

helm repo add minio https://charts.min.io/ # official minio Helm charts
helm repo update
helm install argo-artifacts minio/minio --set service.type=LoadBalancer --set fullnameOverride=argo-artifacts

kubectl로 외부 IP를 확인한 뒤, 웹 브라우저로 MinIO UI에 로그인하세요 (포트 9000).

kubectl get service argo-artifacts

Minikube에서는:

minikube service --url argo-artifacts

참고: MinIO를 Helm으로 설치하면 크리덴셜이 자동 생성되고, 이걸로 UI에 로그인하게 돼요. 아래 명령으로 크리덴셜을 확인할 수 있어요

  • AccessKey: kubectl get secret argo-artifacts -o jsonpath='{.data.accesskey}' | base64 --decode
  • SecretKey: kubectl get secret argo-artifacts -o jsonpath='{.data.secretkey}' | base64 --decode

MinIO UI에서 my-bucket이라는 이름의 버킷을 만드세요.

MinIO가 TLS를 쓰도록 설정되어 있다면 insecure 파라미터를 false로 설정해야 해요. 또한 MinIO가 커스텀 CA가 발급한 인증서로 보호되고 있다면, 먼저 CA 인증서를 쿠버네티스 시크릿에 저장한 뒤 caSecret 파라미터를 그에 맞게 설정해야 해요. 이렇게 해야 Argo가 MinIO가 제시하는 서버 인증서를 올바르게 검증할 수 있어요. 예를 들면:

kubectl create secret generic my-root-ca --from-file=my-ca.pem
artifacts:
  - s3:
      insecure: false
      caSecret:
        name: my-root-ca
        key: my-ca.pem
      ...

AWS S3 설정하기

먼저 버킷을 만들어요:

mybucket=my-bucket-name
aws s3 mb s3://mybucket [--region xxx]

AWS S3 IAM 액세스

다음으로 정책(policy) 파일을 만들어요. 이 정책은 아래 섹션들에서 선택한 인증 방식에 따라 연결하게 돼요.

cat > policy.json <<EOF
{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Effect":"Allow",
         "Action":[
            "s3:PutObject",
            "s3:GetObject",
            "s3:DeleteObject"
         ],
         "Resource":"arn:aws:s3:::$mybucket/*"
      },
      {
         "Effect":"Allow",
         "Action":[
            "s3:ListBucket"
         ],
         "Resource":"arn:aws:s3:::$mybucket"
      }
   ]
}
EOF

Artifact Garbage Collection을 설정하지 않았다면, 위 Actions 목록에서 s3:DeleteObject를 제거해야 해요.

!!! Note "리전(region) 자동 발견"

Argo는 아래 추가 정책으로 버킷의 리전을 자동으로 찾을 수 있어요.
이 정책이 없다면 아티팩트 설정에 리전을 직접 지정해야 해요.

```json
      {
        "Effect":"Allow",
        "Action":[
            "s3:GetBucketLocation"
        ],
        "Resource":"arn:aws:s3:::*"
      }
    ...
```

AWS S3 IRSA

IRSA(IAM Roles for Service Accounts)는 S3에 인증하는 데 권장되는 쿠버네티스 네이티브 메커니즘이에요. EKS를 사용 중이라면 IRSA 설정 가이드를 따르세요. 그렇지 않다면 Pod Identity Webhook 셀프호스팅 설정 가이드를 따르세요.

위에서 만든 버킷과 정책으로 IAM 역할을 만들고 정책을 추가해요:

aws iam create-role --role-name $mybucket-role
aws iam put-role-policy --role-name $mybucket-user --policy-name $mybucket-policy --policy-document file://policy.json

어노테이션으로 이 IAM 역할을 서비스 어카운트에 연결해요:

apiVersion: v1
kind: ServiceAccount
metadata:
  annotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::012345678901:role/mybucket-role
  name: myserviceaccount
  namespace: mynamespace

워크플로우에서 이 서비스 어카운트를 사용해요:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
spec:
  serviceAccountName: myserviceaccount

IAM 액세스 키를 사용하는 AWS S3

!!! Note "최소 권한 사용자" 액세스 키의 권한을 줄이려면, 필요한 권한만 가진 사용자를 만드세요. 그 이상은 넣지 않는 게 좋아요.

위에서 만든 버킷과 정책으로 IAM 사용자를 만들고 정책을 추가해요:

aws iam create-user --user-name $mybucket-user
aws iam put-user-policy --user-name $mybucket-user --policy-name $mybucket-policy --policy-document file://policy.json
aws iam create-access-key --user-name $mybucket-user > access-key.json

액세스 키로 아티팩트를 설정해요:

artifacts:
  - name: my-output-artifact
    path: /my-output-artifact
    s3:
      endpoint: s3.amazonaws.com
      bucket: my-s3-bucket
      key: path/in/bucket/my-output-artifact.tgz
      # The following fields are secret selectors.
      # They reference the k8s secret named 'my-s3-credentials'.
      # This secret is expected to have the keys 'accessKey' and 'secretKey',
      # containing the base64 encoded credentials to the bucket.
      accessKeySecret:
        name: my-s3-credentials
        key: accessKey
      secretKeySecret:
        name: my-s3-credentials
        key: secretKey

IAM Assume Role을 사용하는 AWS S3

v3.6 and after

임시 접근을 위해 IAM 역할을 사용할 수 있어요.

위에서 만든 버킷과 정책으로 IAM 역할을 만들고 정책을 추가해요:

aws iam create-role --role-name $mybucket-role
aws iam put-role-policy --role-name $mybucket-user --policy-name $mybucket-policy --policy-document file://policy.json

역할 크리덴셜을 가져와요:

aws sts assume-role --role-arn arn:aws:iam::012345678901:role/$mybucket-role

크리덴셜로 아티팩트를 설정해요:

artifacts:
  - name: my-output-artifact
    path: /my-output-artifact
    s3:
      endpoint: s3.amazonaws.com
      bucket: my-s3-bucket
      key: path/in/bucket/my-output-artifact.tgz
      # The following fields are secret selectors.
      # They reference the k8s secret named 'my-s3-credentials'.
      # This secret is expected to have the keys 'accessKey', 'secretKey', and 'sessionToken',
      # containing the base64 encoded credentials to the bucket.
      accessKeySecret:
        name: my-s3-credentials
        key: accessKey
      secretKeySecret:
        name: my-s3-credentials
        key: secretKey
      sessionTokenSecret:
        name: my-s3-credentials
        key: sessionToken

!!! Note "임시 크리덴셜" IAM 역할 크리덴셜은 임시이기 때문에, 외부 메커니즘을 통해 주기적으로 갱신해야 해요.

S3 Access Grants를 사용하는 AWS S3

v3.6 and after

임시이면서 범위를 줄인 접근을 위해 S3 Access Grants를 사용할 수 있어요. AWS 계정에 이를 설정하고 access grant 크리덴셜을 받으려면 AWS 가이드를 따르세요.

access grant 크리덴셜로 아티팩트를 설정해요:

artifacts:
  - name: my-output-artifact
    path: /my-output-artifact
    s3:
      endpoint: s3.amazonaws.com
      bucket: my-s3-bucket
      key: path/in/bucket/my-output-artifact.tgz
      # The following fields are secret selectors.
      # They reference the k8s secret named 'my-s3-credentials'.
      # This secret is expected to have the keys 'accessKey', 'secretKey', and 'sessionToken',
      # containing the base64 encoded credentials to the bucket.
      accessKeySecret:
        name: my-s3-credentials
        key: accessKey
      secretKeySecret:
        name: my-s3-credentials
        key: secretKey
      sessionTokenSecret:
        name: my-s3-credentials
        key: sessionToken

!!! Note "임시 크리덴셜" S3 Access Grants는 임시이기 때문에, 외부 메커니즘을 통해 주기적으로 갱신해야 해요.

GCS (Google Cloud Storage) 설정하기

GCP Console에서 버킷을 만드세요 (https://console.cloud.google.com/storage/browser).

Google Cloud Storage를 설정하는 방법은 2가지예요.

네이티브 GCS API 사용

  • Google Cloud 서비스 어카운트 키를 만들고 다운로드해요.
  • 이 키를 저장할 쿠버네티스 시크릿을 만들어요.
  • YAML에서 gcs 아티팩트를 다음처럼 설정해요.
artifacts:
  - name: message
    path: /tmp/message
    gcs:
      bucket: my-bucket-name
      key: path/in/bucket
      # serviceAccountKeySecret is a secret selector.
      # It references the k8s secret named 'my-gcs-credentials'.
      # This secret is expected to have the key 'serviceAccountKey',
      # containing the base64 encoded credentials
      # to the bucket.
      #
      # If it's running on GKE and Workload Identity is used,
      # serviceAccountKeySecret is not needed.
      serviceAccountKeySecret:
        name: my-gcs-credentials
        key: serviceAccountKey

GKE 클러스터에서 Workload Identity가 설정되어 있다면, 서비스 어카운트 키를 만들어 쿠버네티스 시크릿에 저장할 필요가 없어요. 이 경우 serviceAccountKeySecret도 필요 없고요. Workload Identity 설정 방법은 링크를 따라가 보세요 (https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity).

S3 API 사용

S3 호환 액세스를 활성화하고 액세스 키를 만드세요. S3 호환 액세스는 버킷 단위가 아니라 프로젝트 단위로 설정된다는 점을 기억하세요.

  • Storage > Settings로 이동해요 (https://console.cloud.google.com/storage/settings).
  • 필요하면 상호운용성(interoperability) 액세스를 활성화해요.
  • 필요하면 새 키를 만들어요.
  • s3 아티팩트를 다음 예제처럼 설정해요.
artifacts:
  - name: my-output-artifact
    path: /my-output-artifact
    s3:
      endpoint: storage.googleapis.com
      bucket: my-gcs-bucket-name
      # NOTE that, by default, all output artifacts are automatically tarred and
      # gzipped before saving. So as a best practice, .tgz or .tar.gz
      # should be incorporated into the key name so the resulting file
      # has an accurate file extension.
      key: path/in/bucket/my-output-artifact.tgz
      accessKeySecret:
        name: my-gcs-s3-credentials
        key: accessKey
      secretKeySecret:
        name: my-gcs-s3-credentials
        key: secretKey

Alibaba Cloud OSS (Object Storage Service) 설정하기

버킷을 만들고, 그 버킷용 액세스 키를 만드세요. 액세스 키의 권한을 제한하는 걸 추천해요. 그러려면 액세스 키에 연결할 권한만 가진 사용자를 만들어야 해요. 아니면 기존 사용자 계정으로 액세스 키를 만들어도 돼요.

Alibaba Cloud CLI를 설정하고, 다음 단계를 따라 워크플로우용 아티팩트 스토리지를 구성해 보세요:

$ export mybucket=bucket-workflow-artifect
$ export myregion=cn-zhangjiakou
$ # limit permission to read/write the bucket.
$ cat > policy.json <<EOF
{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
              "oss:PutObject",
              "oss:GetObject"
            ],
            "Resource": "acs:oss:*:*:$mybucket/*"
        }
    ]
}
EOF
$ # create bucket.
$ aliyun oss mb oss://$mybucket --region $myregion
$ # show endpoint of bucket.
$ aliyun oss stat oss://$mybucket
$ #create a ram user to access bucket.
$ aliyun ram CreateUser --UserName $mybucket-user
$ # create ram policy with the limit permission.
$ aliyun ram CreatePolicy --PolicyName $mybucket-policy --PolicyDocument "$(cat policy.json)"
$ # attach ram policy to the ram user.
$ aliyun ram AttachPolicyToUser --UserName $mybucket-user --PolicyName $mybucket-policy --PolicyType Custom
$ # create access key and secret key for the ram user.
$ aliyun ram CreateAccessKey --UserName $mybucket-user > access-key.json
$ # create secret in demo namespace, replace demo with your namespace.
$ kubectl create secret generic $mybucket-credentials -n demo\
  --from-literal "accessKey=$(cat access-key.json | jq -r .AccessKey.AccessKeyId)" \
  --from-literal "secretKey=$(cat access-key.json | jq -r .AccessKey.AccessKeySecret)"
$ # create configmap to config default artifact for a namespace.
$ cat > default-artifact-repository.yaml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
  # If you want to use this config map by default, name it "artifact-repositories". Otherwise, you can provide a reference to a
  # different config map in `artifactRepositoryRef.configMap`.
  name: artifact-repositories
  annotations:
    # v3.0 and after - if you want to use a specific key, put that key into this annotation.
    workflows.argoproj.io/default-artifact-repository: default-oss-artifact-repository
data:
  default-oss-artifact-repository: |
    oss:
      endpoint: http://oss-cn-zhangjiakou-internal.aliyuncs.com
      bucket: $mybucket
      # accessKeySecret and secretKeySecret are secret selectors.
      # It references the k8s secret named 'bucket-workflow-artifect-credentials'.
      # This secret is expected to have the keys 'accessKey'
      # and 'secretKey', containing the base64 encoded credentials
      # to the bucket.
      accessKeySecret:
        name: $mybucket-credentials
        key: accessKey
      secretKeySecret:
        name: $mybucket-credentials
        key: secretKey
EOF
# create cm in demo namespace, replace demo with your namespace.
$ k apply -f default-artifact-repository.yaml -n demo

createBucketIfNotPresent를 true로 설정하면, 아티팩트를 저장할 때 OSS 버킷이 아직 없으면 아티팩트 드라이버가 자동으로 만들게 할 수 있어요. 이 경우 OSS 계정에 새 버킷을 만들 수 있는 추가 권한을 설정해야 한다는 점을 기억하세요.

Alibaba Cloud OSS RRSA

accessKey와 secretKey를 직접 넘겨 주는 대신 OSS RRSA를 사용하고 싶다면, 다음 작업을 수행해야 해요:

  • 클러스터에 pod-identity-webhook을 설치해서 OIDC 토큰과 환경 변수가 자동으로 주입되게 하세요.
  • 대상 워크플로우 네임스페이스에 레이블 pod-identity.alibabacloud.com/injection: 'on'을 추가하세요.
  • 워크플로우를 실행하는 서비스 어카운트에 어노테이션 pod-identity.alibabacloud.com/role-name: $your_ram_role_name을 추가하세요.
  • 대상 아티팩트 저장소 config map에서 useSDKCreds: true를 설정하고 AK/SK에 대한 시크릿 참조는 제거하세요.

apiVersion: v1
kind: Namespace
metadata:
  name: my-ns
  labels:
    pod-identity.alibabacloud.com/injection: 'on'

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: my-sa
  namespace: rrsa-demo
  annotations:
    pod-identity.alibabacloud.com/role-name: $your_ram_role_name

---
apiVersion: v1
kind: ConfigMap
metadata:
  # If you want to use this config map by default, name it "artifact-repositories". Otherwise, you can provide a reference to a
  # different config map in `artifactRepositoryRef.configMap`.
  name: artifact-repositories
  annotations:
    # v3.0 and after - if you want to use a specific key, put that key into this annotation.
    workflows.argoproj.io/default-artifact-repository: default-oss-artifact-repository
data:
  default-oss-artifact-repository: |
    oss:
      endpoint: http://oss-cn-zhangjiakou-internal.aliyuncs.com
      bucket: $mybucket
      useSDKCreds: true

Azure Blob Storage 설정하기

Azure Storage 계정을 만들고, 그 계정 안에 컨테이너를 만드세요. Azure Portal, CLI, 또는 다른 도구를 사용할 수 있어요.

Argo를 Azure 스토리지 계정에 인증하는 방법은 여러 가지예요:

Azure Managed Identities 사용하기

Azure Managed Identities는 Azure 리소스 접근을 안전하게 관리하는 데 선호되는 방법이에요. Managed Identity가 할당되어 있다면 useSDKCreds: true를 설정할 수 있어요. 이 경우 accountKeySecret은 사용되지 않고, 인증은 DefaultAzureCredential을 사용해요.

artifacts:
  - name: message
    path: /tmp/message
    azure:
      endpoint: https://mystorageaccountname.blob.core.windows.net
      container: my-container-name
      blob: path/in/container
      # If a managed identity has been assigned to the machines running the
      # workflow (for example, https://docs.microsoft.com/en-us/azure/aks/use-managed-identity)
      # then useSDKCreds should be set to true. The accountKeySecret is not required
      # and will not be used in this case.
      useSDKCreds: true

Azure Access Keys 사용하기

Access Key를 사용할 수도 있어요.

  1. 스토리지 계정의 blob 서비스 엔드포인트를 확인해요:

    az storage account show -n mystorageaccountname --query 'primaryEndpoints.blob' -otsv
    # https://mystorageaccountname.blob.core.windows.net
    
  2. 스토리지 계정의 Access Key를 확인해요:

    ACCESS_KEY="$(az storage account keys list -n mystorageaccountname --query '[0].value' -otsv)"
    
  3. 스토리지 계정 키를 담을 쿠버네티스 시크릿을 만들어요:

    kubectl create secret generic my-azure-storage-credentials \
      --from-literal "account-access-key=$ACCESS_KEY"
    
  4. azure 아티팩트를 설정해요:

    artifacts:
      - name: message
        path: /tmp/message
        azure:
          endpoint: https://mystorageaccountname.blob.core.windows.net
          container: my-container-name
          blob: path/in/container
          # accountKeySecret is a secret selector.
          # It references the Kubernetes Secret named 'my-azure-storage-credentials'.
          # This secret is expected to have the key 'account-access-key',
          # containing the base64 encoded credentials to the storage account.
          accountKeySecret:
            name: my-azure-storage-credentials
            key: account-access-key
    

Azure Shared Access Signatures (SAS) 사용하기

v3.6 and after

Shared Access Signature (SAS)를 사용할 수도 있어요.

  1. 스토리지 계정의 blob 서비스 엔드포인트를 확인해요:

    az storage account show -n mystorageaccountname --query 'primaryEndpoints.blob' -otsv
    # https://mystorageaccountname.blob.core.windows.net
    
  2. 스토리지 계정용 Shared Access Signature를 생성해요:

    SAS_TOKEN="$(az storage container generate-sas --account-name <storage-account> --name <container> --permissions acdlrw --expiry <date-time> --auth-mode key)"
    
  3. 스토리지 계정 키를 담을 쿠버네티스 시크릿을 만들어요:

    kubectl create secret generic my-azure-storage-credentials \
      --from-literal "shared-access-key=$SAS_TOKEN"
    
  4. azure 아티팩트를 설정해요:

    artifacts:
      - name: message
        path: /tmp/message
        azure:
          endpoint: https://mystorageaccountname.blob.core.windows.net
          container: my-container-name
          blob: path/in/container
          # accountKeySecret is a secret selector.
          # It references the Kubernetes Secret named 'my-azure-storage-credentials'.
          # This secret is expected to have the key 'shared-access-key',
          # containing the base64 encoded shared access signature to the storage account.
          accountKeySecret:
            name: my-azure-storage-credentials
            key: shared-access-key
    

기본 아티팩트 저장소 설정하기

Argo가 여러분의 아티팩트 저장소를 사용하도록 하려면, 기본(default) 저장소로 설정할 수 있어요. workflow-controller config map을 편집해서 여러분의 저장소에 맞는 엔드포인트와 액세스/시크릿 키를 지정하세요.

S3 호환 아티팩트 저장소 버킷 (AWS, GCS, MinIO, Alibaba Cloud OSS 등)

여러분의 프로바이더에 맞는 endpoint를 사용하세요:

  • AWS: s3.amazonaws.com
  • GCS: storage.googleapis.com
  • MinIO: my-minio-endpoint.default:9000
  • Alibaba Cloud OSS: oss-cn-hangzhou-zmf.aliyuncs.com

key는 bucket 안에서 오브젝트의 이름이에요. accessKeySecret과 secretKeySecret은 지정된 쿠버네티스 시크릿을 참조하는 시크릿 셀렉터(secret selector)예요. 이 시크릿에는 버킷 접근용 base64 인코딩 크리덴셜이 담긴 accessKey와 secretKey 키가 있어야 해요.

AWS에서는 accessKeySecret과 secretKeySecret이 각각 AWS_ACCESS_KEY_ID와 AWS_SECRET_ACCESS_KEY에 해당해요.

EC2는 메타데이터 API를 제공하고, AWS SDK를 사용하는 애플리케이션은 이 API를 통해 인스턴스에 연결된 IAM 역할을 assume할 수 있어요. Argo를 EC2에서 실행 중이고 인스턴스 역할이 S3 버킷 접근을 허용한다면, 워크플로우 스텝 파드가 그 역할을 assume하도록 설정할 수 있어요. 그러려면 그냥 accessKeySecret과 secretKeySecret 필드를 생략하면 돼요.

GCS의 S3 호환 액세스용 accessKeySecret과 secretKeySecret은 GCP Console에서 얻을 수 있어요. S3 호환 액세스는 버킷 단위가 아니라 프로젝트 단위로 설정된다는 점을 기억하세요.

MinIO에서는 accessKeySecret과 secretKeySecret이 자연스럽게 AccessKey와 SecretKey에 해당해요.

Alibaba Cloud OSS에서는 accessKeySecret과 secretKeySecret이 각각 accessKeyID and accessKeySecret에 해당해요.

예제:

$ kubectl edit configmap workflow-controller-configmap -n argo  # assumes argo was installed in the argo namespace
...
data:
  artifactRepository: |
    s3:
      bucket: my-bucket
      keyFormat: prefix/in/bucket     #optional
      endpoint: my-minio-endpoint.default:9000        #AWS => s3.amazonaws.com; GCS => storage.googleapis.com
      insecure: true                  #omit for S3/GCS. Needed when minio runs without TLS
      accessKeySecret:                #omit if accessing via AWS IAM
        name: my-minio-cred
        key: accessKey
      secretKeySecret:                #omit if accessing via AWS IAM
        name: my-minio-cred
        key: secretKey
      useSDKCreds: true               #tells argo to use AWS SDK's default provider chain, enable for things like IRSA support
      addressingStyle: "virtual-hosted" #optional; "" (auto-detect, default), "path", or "virtual-hosted". Set for providers that only support virtual-hosted-style addressing

시크릿은 워크플로우를 실행하는 네임스페이스에서 가져와요. keyFormat을 지정할 수 있다는 점도 기억하세요.

일부 S3 호환 프로바이더는 virtual-hosted-style 버킷 주소 지정만 지원하고 path-style 요청은 거부해요. 주소 지정 오류를 만난다면 addressingStyle을 virtual-hosted로 설정하세요 (또는 path-style을 강제하려면 path로). 기본값 ""는 클라이언트가 자동으로 감지하게 해요.

Google Cloud Storage (GCS)

Argo는 네이티브 GCS API로 Google Cloud Storage 버킷에 접근할 수도 있어요.

serviceAccountKeySecret은 버킷 접근용 Google Cloud 서비스 어카운트 키를 저장하는 쿠버네티스 시크릿을 참조해요.

예제:

$ kubectl edit configmap workflow-controller-configmap -n argo  # assumes argo was installed in the argo namespace
...
data:
  artifactRepository: |
    gcs:
      bucket: my-bucket
      keyFormat: prefix/in/bucket/{{workflow.name}}/{{pod.name}}     #it should reference workflow variables, such as "{{workflow.name}}/{{pod.name}}"
      serviceAccountKeySecret:
        name: my-gcs-credentials
        key: serviceAccountKey

Azure Blob Storage

Argo는 네이티브 Azure API로 Azure Blob Storage 컨테이너에 접근할 수도 있어요.

accountKeySecret은 컨테이너 접근용 Azure Blob Storage 계정 공유 키(shared key)를 저장하는 쿠버네티스 시크릿을 참조해요.

예제:

$ kubectl edit configmap workflow-controller-configmap -n argo  # assumes argo was installed in the argo namespace
...
data:
  artifactRepository: |
    azure:
      container: my-container
      blobNameFormat: prefix/in/container     #optional, it could reference workflow variables, such as "{{workflow.name}}/{{pod.name}}"
      accountKeySecret:
        name: my-azure-storage-credentials
        key: account-access-key

기본이 아닌 아티팩트 저장소 접근하기

이 섹션은 기본이 아닌(non-default) 아티팩트 저장소에서 아티팩트에 접근하는 방법을 보여 줘요.

endpoint, accessKeySecret, secretKeySecret은 앞서 설명한 기본 아티팩트 저장소 설정과 동일해요.

  templates:
  - name: artifact-example
    inputs:
      artifacts:
      - name: my-input-artifact
        path: /my-input-artifact
        s3:
          endpoint: s3.amazonaws.com
          bucket: my-aws-bucket-name
          key: path/in/bucket/my-input-artifact.tgz
          accessKeySecret:
            name: my-aws-s3-credentials
            key: accessKey
          secretKeySecret:
            name: my-aws-s3-credentials
            key: secretKey
    outputs:
      artifacts:
      - name: my-output-artifact
        path: /my-output-artifact
        s3:
          endpoint: storage.googleapis.com
          bucket: my-gcs-bucket-name
          # NOTE that, by default, all output artifacts are automatically tarred and
          # gzipped before saving. So as a best practice, .tgz or .tar.gz
          # should be incorporated into the key name so the resulting file
          # has an accurate file extension.
          key: path/in/bucket/my-output-artifact.tgz
          accessKeySecret:
            name: my-gcs-s3-credentials
            key: accessKey
          secretKeySecret:
            name: my-gcs-s3-credentials
            key: secretKey
          region: my-GCS-storage-bucket-region
    container:
      image: debian:latest
      command: [sh, -c]
      args: ["cp -r /my-input-artifact /my-output-artifact"]

아티팩트 플러그인 사용하기

v4.0 and after

Argo Workflows는 플러그인 시스템을 통해 확장 가능한 아티팩트 드라이버를 지원해요. 아티팩트 플러그인을 쓰면 대체 스토리지 솔루션과 통합하거나, 특수한 아티팩트 처리 로직을 구현할 수 있어요.

아티팩트 플러그인이란?

아티팩트 플러그인은 아티팩트 드라이버 인터페이스를 GRPC로 구현하는 컨테이너화된 확장 기능이에요. 아티팩트 연산을 처리하기 위해 워크플로우 파드와 함께 사이드카(sidecar)와 init 컨테이너로 실행돼요. 각 플러그인은 필요한 의존성을 모두 담은 Docker 이미지로 배포돼요.

플러그인 설정

아티팩트 플러그인을 사용하려면 세 곳에서 설정해야 해요:

  1. 시스템 설정(System Configuration): 워크플로우 컨트롤러 ConfigMap에 사용 가능한 플러그인을 등록해요.
  2. Argo Server 설정: argo-server Deployment에 사용 가능한 플러그인을 사이드카로 추가해요.
  3. 워크플로우 사용: 워크플로우 아티팩트 정의에서 플러그인을 참조해요.

시스템 설정

플러그인은 워크플로우 컨트롤러 ConfigMap의 artifactDrivers 섹션 아래에 등록해야 해요. 이를 통해 시스템 관리자가 어떤 플러그인을 사용할 수 있는지, 그 버전은 무엇인지 통제할 수 있어요.

artifactDrivers 필드의 상세 설정은 Workflow Controller ConfigMap 문서를 참고하세요.

워크플로우 컨트롤러 ConfigMap 설정 예제:

apiVersion: v1
kind: ConfigMap
metadata:
  name: workflow-controller-configmap
data:
  artifactDrivers: |
    - name: my-custom-plugin
      image: quay.io/myorg/my-artifact-plugin:v1.0.0
    - name: another-plugin
      image: docker.io/myorg/another-plugin:v2.1.0

Argo Server 설정

플러그인은 argo-server Deployment에 사이드카로 추가해야 해요. 각 플러그인 사이드카는 공유 볼륨 위의 Unix 소켓을 통해 argo-server 컨테이너와 통신해요.

플러그인 사이드카는 소켓 경로를 첫 번째이자 유일한 커맨드라인 인자로 받아요. 플러그인 사이드카와 메인 argo-server 컨테이너 둘 다 같은 위치에 공유 볼륨을 마운트해야 소켓 통신이 가능해요. 소켓은 /tmp/artifact-plugins/{plugin-name}/socket 위치에 있어야 하고, {plugin-name}은 워크플로우 컨트롤러 ConfigMap에 설정된 플러그인 이름과 일치해야 해요.

argo-server에 플러그인 사이드카 두 개를 추가하는 설정 예제:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: argo-server
spec:
  template:
    spec:
      containers:
        - name: argo-server
          image: quay.io/argoproj/argocli:latest
          volumeMounts:
            - name: my-custom-plugin
              mountPath: /tmp/artifact-plugins/my-custom-plugin
            - name: another-plugin
              mountPath: /tmp/artifact-plugins/another-plugin
        - name: my-custom-plugin-artifact-driver
          image: quay.io/myorg/my-artifact-plugin:v1.0.0
          args:
            - /tmp/artifact-plugins/my-custom-plugin/socket
          volumeMounts:
            - name: my-custom-plugin
              mountPath: /tmp/artifact-plugins/my-custom-plugin
        - name: another-plugin-artifact-driver
          image: docker.io/myorg/another-plugin:v2.1.0
          args:
            - /tmp/artifact-plugins/another-plugin/socket
          volumeMounts:
            - name: another-plugin
              mountPath: /tmp/artifact-plugins/another-plugin
      volumes:
        - name: my-custom-plugin
          emptyDir: {}
        - name: another-plugin
          emptyDir: {}

설정의 핵심 요구 사항은 이래요:

  • 플러그인마다 자신의 전용 볼륨과 /tmp/artifact-plugins/{plugin-name} 마운트 경로가 필요해요.
  • 소켓 경로는 /tmp/artifact-plugins/{plugin-name}/socket이어야 하고, {plugin-name}은 워크플로우 컨트롤러의 artifactDrivers 설정에 있는 name 필드와 정확히 일치해야 해요.
  • argo-server 컨테이너와 플러그인 사이드카 둘 다 같은 볼륨을 같은 경로에 마운트해야 해요.
  • 소켓 파일 이름은 반드시 socket이어야 해요 (임의로 정하면 안 돼요). 코드가 그 이름을 기대하기 때문이에요.
  • Unix 소켓에 효율적인 공유 스토리지를 제공하는 emptyDir 볼륨을 사용하세요.

워크플로우에서 사용하기

일단 등록되면, 아티팩트 정의에 plugin 필드를 지정해서 워크플로우에서 플러그인을 사용할 수 있어요:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
spec:
  templates:
  - name: plugin-example
    inputs:
      artifacts:
      - name: my-input
        path: /tmp/input
        plugin:
          name: my-custom-plugin
          configuration: |
            endpoint: https://my-storage.example.com
            bucket: my-bucket
            credentials:
              username: myuser
              password: mypass
          key: path/to/my-artifact
    outputs:
      artifacts:
      - name: my-output
        path: /tmp/output
        plugin:
          name: my-custom-plugin
          configuration: |
            endpoint: https://my-storage.example.com
            bucket: my-bucket
            credentials:
              username: myuser
              password: mypass
          key: path/to/output-artifact

플러그인을 기본 아티팩트 저장소로 설정해서 시스템 전역 플러그인 설정으로 쓸 수도 있어요. 이렇게 하면 다른 아티팩트 스토어와 마찬가지로 key만 있는 아티팩트(key only artifacts)도 사용할 수 있어요.

플러그인 파라미터

plugin 아티팩트 유형은 다음 파라미터를 지원해요:

파라미터 유형 필수 여부 설명
name string 예 artifactDrivers에 설정된 플러그인의 이름
configuration string 예 플러그인에 그대로 전달되는 플러그인별 설정
key string 예 플러그인의 스토리지 시스템에서 아티팩트가 저장되는 경로/키. 사용 방법은 플러그인마다 달라요
connectionTimeoutSeconds int32 아니요 이미지가 시작된 후 GRPC 클라이언트 연결에 대한 타임아웃 (기본값: 5초)

설정 형식

configuration 필드는 플러그인으로 곧장 전달되는 자유 형식 문자열이에요. 플러그인이 어떤 형식이든 쓸 수 있지만, 일관성과 가독성을 위해 YAML을 강하게 추천해요. 각 플러그인이 자체 설정 스키마를 정의하니, 세부 요구 사항은 플러그인의 문서를 참고하세요.

사용 가능한 플러그인

플러그인은 Argo Workflows 코어와 별도로 개발되고 유지 관리돼요. 사용 방법, 설정 옵션, 사용 예제는 플러그인의 문서를 확인하세요.

자신만의 아티팩트 플러그인을 만들고 싶은 개발자는 Artifact Plugin 개발 가이드를 참고하세요.

아티팩트 스트리밍 (Artifact Streaming)

아티팩트 스트리밍을 쓰면 아티팩트를 먼저 디스크에 저장할 필요가 없어요. 아티팩트 스트리밍은 다음 아티팩트 드라이버만 지원해요: S3 (v3.4+), Azure Blob (v3.4+), HTTP (v3.5+), Artifactory (v3.5+), OSS (v3.6+), 그리고 Plugin (v4.0+).

아티팩트 스트리밍이 없을 때는, 사용자가 UI에서 아티팩트 다운로드 버튼을 누르면 아티팩트를 먼저 Argo Server의 디스크에 기록한 뒤에야 다운로드할 수 있었어요. 여러 사용자가 동시에 다운로드하려고 하면 디스크 공간을 차지하고 다운로드가 실패하기도 했죠.

더 알아보기 (Learn more)

  • Artifact Repository Ref 문서에서 워크플로우별 저장소 참조 방법을 살펴 보세요.
  • 아티팩트 가이드에서 아티팩트 사용법 전반과 가비지 컬렉션을 확인해 보세요.
  • 아티팩트 스트리밍은 S3(v3.4+), Azure Blob(v3.4+), HTTP(v3.5+), Artifactory(v3.5+), OSS(v3.6+), Plugin(v4.0+) 드라이버만 지원한다는 점을 기억하세요.