argocd: How to override imagetag with git SHA in argocd manifest file?

855 Views Asked by At

Below is part of my values.yaml values.yaml

image:
  tag: "${CI_COMMIT_SHORT_SHA}"

While running the installtion in git CI, I can easily pass the override as below.

helm install <release name> --set image.tag=${CI_COMMIT_SHORT_SHA}  <chart name>

Now, We have written the argocd application manifest to install the helm. But not sure how can we pass refer and pass commit SHA id as image tag override.

argocd manifest file as below.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  destination:
    namespace: my-app
    server: 'https://destination-cluster'
  project: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
  source:
    repoURL: 'https://my-git-service/repo/my-app.git'
    path: chart/my-app
    targetRevision: main
    helm:
      image.tag: <Here-I-Need-SHA-Value>

Any help would be great!

1

There are 1 best solutions below

0
JesseBot On

You can use four different methods at time of writing:

You can use spec.source.helm.parameters

source:
  helm:
    parameters:
    - name: "image.tag"
      value: "my-image-tag"

or spec.source.helm.valueFiles to reference a values file:

source:
  helm:
    valueFiles:
    - values-overide.yaml

or spec.source.helm.valuesObject for providing them as in object:

source:
  helm:
    valuesObject:
      image:
        tag: "my-image-tag"

or spec.source.helm.values for providing in-line values:

source:
  helm:
    values: |
      image:
        tag: "my-image-tag"

A full Argo CD helm app using spec.source.helm.valuesObject to pass in image.tag to the bitnami sealed secrets helm chart:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: sealed-secrets
  namespace: argocd
spec:
  project: default
  destination:
    server: "https://kubernetes.default.svc"
    namespace: kubeseal
  source:
    chart: bitnamicharts/sealed-secrets
    repoURL: oci://registry-1.docker.io
    targetRevision: 1.5.3
    helm:
      releaseName: sealed-secrets
      valuesObject:
        image:
          tag: "0.24.0-debian-11-r0"