argocd-image-updater icon indicating copy to clipboard operation
argocd-image-updater copied to clipboard

Multiple secrets for the same registry

Open biclighter81 opened this issue 1 year ago • 2 comments

This is a pull request based on the following issue: https://github.com/argoproj-labs/argocd-image-updater/issues/639

If you have multiple credentials for the same registry maybe because you want to pull private images from two different authors, the image updater currently can't pick the correct credentials for the job. My code checks if the argo application has a registry-prefix annotation. If it has one it picks the correct registry via the prefix configured in your registry configuration.

Example registry configuration

- name: GHCR author1
  api_url: https://ghcr.io
  prefix: ghcr.io/author1
  credentials: ext:/some/script
  credsexpire: 5h
- name: GHCR author2
  api_url: https://ghcr.io
  prefix: ghcr.io/author2
  credentials: ext:/some/script
  credsexpire: 5h

Example application configuration

argocd-image-updater.argoproj.io/app-author1.helm.image-name: app-author1.image.repository
argocd-image-updater.argoproj.io/app-author1.helm.image-tag: app-author1.image.tag
argocd-image-updater.argoproj.io/app-author1.registry-prefix: author1
argocd-image-updater.argoproj.io/app-author1.update-strategy: digest

argocd-image-updater.argoproj.io/app-author2.helm.image-name: app-author2.image.repository
argocd-image-updater.argoproj.io/app-author2.helm.image-tag: app-author2.image.tag
argocd-image-updater.argoproj.io/app-author2.registry-prefix: author2
argocd-image-updater.argoproj.io/app-author2.update-strategy: digest

I hope it helps someone.

biclighter81 avatar Nov 11 '23 11:11 biclighter81

Codecov Report

Merging #642 (0b302af) into master (82d59ef) will decrease coverage by 0.05%. The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master     #642      +/-   ##
==========================================
- Coverage   65.35%   65.30%   -0.05%     
==========================================
  Files          22       22              
  Lines        2084     2087       +3     
==========================================
+ Hits         1362     1363       +1     
- Misses        588      589       +1     
- Partials      134      135       +1     
Files Coverage Δ
pkg/argocd/update.go 66.18% <50.00%> (-0.36%) :arrow_down:

:mega: Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

codecov-commenter avatar Nov 11 '23 11:11 codecov-commenter

I tried updating the image on the argocd-image-updater we use to the one built from this branch. If I keep using the argocd-i-u 0.9.3 helm chart it works fine, but if I try updating the helm chart to 0.9.7 with the same Helm values then the pod fails to fetch any image. I'll investigate some more the changes between the 0.9.3 and .7 helm chart.

bebosudo avatar Apr 26 '24 16:04 bebosudo