4. Argo Image Updater 를 이용한 이미지 자동 배포 (helm) - 2232

4-1. Image Updater values-dev.yaml 파일 확인

config:
  argocd:
    serverAddress: "<https://argo-cd-argocd-server>"

  registries:
    - name: Docker Hub
      api_url: <https://registry-1.docker.io>
      #credentials: env:DOCKER_HUB_CREDS=username:passowrd

4-2. Image Updater 설치 시 Jenkinsfile에 적용된 Docker연결 내용

HELM_DEPLOY_COMMAND =  "helm upgrade ${params.TARGET_ARGO} ./${INSTALL_PATH}/helm/${params.TARGET_ARGO} " +
" -f ./${INSTALL_PATH}/helm/${params.TARGET_ARGO}/values-dev.yaml" + " -n argo --install --kubeconfig " + '${KUBECONFIG}' +
" --wait --timeout=10m "  

// image-updater일 경우 도커허브 credentials 주입
if (params.TARGET_ARGO == "argocd-image-updater") {
withCredentials([usernamePassword(credentialsId: 'docker_password', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {
    HELM_DEPLOY_COMMAND += " --set config.registries[0].credentials=env:DOCKER_HUB_CREDS="+ '${USERNAME}' + ":" + '${PASSWORD}'
    }
}

sh "eval ${HELM_DEPLOY_COMMAND}"

4-3. Jenkins에서 배포

▶ Dashboard > add-on > deploy-argo > 파라미터와 함께 빌드

DEPLOY_TYPE : helm_upgrade
TARGET_ARGO : argocd-image-updater

4-4. Image Updater 동작 확인

- Pod 로그 내용

time="2024-01-12T01:13:08Z" level=info msg="Starting image update cycle, considering 1 annotated application(s) for update"
time="2024-01-12T01:13:10Z" level=info msg="Processing results: applications=1 images_considered=1 images_skipped=0 images_updated=0 errors=0"
time="2024-01-12T01:15:11Z" level=info msg="Starting image update cycle, considering 1 annotated application(s) for update"
time="2024-01-12T01:15:13Z" level=info msg="Processing results: applications=1 images_considered=1 images_skipped=0 images_updated=0 errors=0"
time="2024-01-12T01:17:13Z" level=info msg="Starting image update cycle, considering 1 annotated application(s) for update"
time="2024-01-12T01:17:15Z" level=info msg="Processing results: applications=1 images_considered=1 images_skipped=0 images_updated=0 errors=0"

4-5. 자동 배포 설정 방법

4-5-1. Application > api-tester-2232 > [DETAILS] 클릭

image.png

4-5-2. SUMMARY > [EDIT] 클릭

4-5-3. ANNOTATIONS 내용 입력 후 > [SAVE] 클릭

#Username으로 수정
// 도커 허브에서 이미지 대상 지정
argocd-image-updater.argoproj.io/image-list=<alias>=<Dockerhub-Username>/api-tester
// ex) argocd-image-updater.argoproj.io/image-list=1pro-api-tester=1pro/api-tester

// 업데이트 전략 선택
argocd-image-updater.argoproj.io/<alias>.update-strategy=name
// ex) argocd-image-updater.argoproj.io/1pro-api-tester.update-strategy=name

// 태그 정규식 설정 (1.1.1-231220.175735) 
argocd-image-updater.argoproj.io/<alias>.allow-tags=regexp:^1.1.1-[0-9]{6}.[0-9]{6}$
// ex) argocd-image-updater.argoproj.io/1pro-api-tester.allow-tags=regexp:^1.1.1-[0-9]{6}.[0-9]{6}$

4-5-4. SYNC POLICY에서 [ENABLE AUTO-SYNC] 클릭해서 아래 상태로 변경

image.png