커스텀 도구

커스텀 도구 (Custom Tooling)

Argo CD는 지원하는 템플릿 도구(helm, kustomize, ks, jsonnet)의 선호 버전을 컨테이너 이미지에 번들로 포함하고 있어요. 때로는 Argo CD가 번들한 버전이 아닌 특정 버전의 도구를 사용하고 싶을 때가 있어요. 그 이유는 다음과 같아요:

출처: 문서

본문

  • 버그나 버그 수정 때문에 도구를 특정 버전으로 업그레이드/다운그레이드하려는 경우
  • kustomize의 configmap/secret 생성기가 사용할 추가 의존성을 설치하려는 경우 (예: curl, vault, gpg, AWS CLI)
  • 설정 관리 플러그인 (config management plugin)을 설치하려는 경우

Argo CD 리포지토리 서버(repo-server)는 Kubernetes 매니페스트를 생성하는 단일 서비스이므로, 환경에 필요한 대체 도구 체인을 사용하도록 커스터마이즈할 수 있어요.

볼륨 마운트로 도구 추가 (Adding Tools Via Volume Mounts)

첫 번째 기법은 init 컨테이너와 volumeMount를 사용해 다른 버전의 도구를 repo-server 컨테이너로 복사하는 것이에요. 아래 예시에서 init 컨테이너는 helm 바이너리를 Argo CD에 번들된 버전과 다른 버전으로 덮어써요:

    spec:
      # 1. Define an emptyDir volume which will hold the custom binaries
      volumes:
      - name: custom-tools
        emptyDir: {}
      # 2. Use an init container to download/copy custom binaries into the emptyDir
      initContainers:
      - name: download-tools
        image: alpine:3.8
        command: [sh, -c]
        args:
        - wget -qO- https://get.helm.sh/helm-v2.12.3-linux-amd64.tar.gz | tar -xvzf - &&
          mv linux-amd64/helm /custom-tools/
        volumeMounts:
        - mountPath: /custom-tools
          name: custom-tools
      # 3. Volume mount the custom binary to the bin directory (overriding the existing version)
      containers:
      - name: argocd-repo-server
        volumeMounts:
        - mountPath: /usr/local/bin/helm
          name: custom-tools
          subPath: helm

BYOI (내 이미지 만들기, Build Your Own Image)

때로는 바이너리를 교체하는 것만으로 부족하고 다른 의존성을 설치해야 할 때가 있어요. 아래 예시는 Dockerfile에서 완전히 커스터마이즈된 repo-server를 빌드해서, 매니페스트 생성에 필요할 수 있는 추가 의존성을 설치해요:

FROM argoproj/argocd:v2.5.4 # Replace tag with the appropriate argo version

# Switch to root for the ability to perform install
USER root

# Install tools needed for your repo-server to retrieve & decrypt secrets, render manifests 
# (e.g. curl, awscli, gpg, sops)
RUN apt-get update && \
    apt-get install -y \
        curl \
        awscli \
        gpg && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    curl -o /usr/local/bin/sops -L https://github.com/mozilla/sops/releases/download/3.2.0/sops-3.2.0.linux && \
    chmod +x /usr/local/bin/sops

# Switch back to non-root user
USER $ARGOCD_USER_ID

더 알아보기 (Learn more)