ArgoCD application manifest with variables

676 Views Asked by At

I am using Argocd to deploy my application.
Kubernetes resources are deployed using a Helm chart located in AWS ECR.

I'm currently utilizing an Argocd application manifest stored in a Git repository, this manifest is pointing to the Helm Chart RepoURL in ECR:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: app
  namespace: argocd
spec:
  sources:
  - repoURL: 1234567890.dkr.ecr.us-east-1.amazonaws.com
    path: .
    chart: app-helm
    targetRevision: 3.2
  destination:
    server: https://kubernetes.default.svc
    namespace: default
  project: default
  syncPolicy:
    syncOptions:
    - CreateNamespace=true

ArgoCD application in the UI is pointing to a git repo with this ArgoCD application manifest. So the application creates another application (app of apps).
The manifest shows that the RepoURL contains the AWS_ACCOUNT_ID and AWS_REGION.
I'm aiming to configure these parameters in the manifest as environment variables like this, and to somehow inject these parameters (e.g., secrets, configmaps) without static configuration:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: app
  namespace: argocd
spec:
  sources:
  - repoURL: ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com
    path: .
    chart: app-helm
    targetRevision: 0.3.2
  destination:
    server: https://kubernetes.default.svc
    namespace: default
  project: default
  syncPolicy:
    syncOptions:
    - CreateNamespace=true

Any suggestion?

1

There are 1 best solutions below

0
On

Wrap the application in your Git repo with a simple Helm chart

spec:
  sources:
    - repoURL: {{ .Values.AWS_ACCOUNT_ID }}.dkr.ecr.{{ .Values.AWS_REGION }}.amazonaws.com

Then add this to the app of apps:

helm:
  valuesObject:
    AWS_ACCOUNT_ID: "1234567890"
    AWS_REGION: "us-east-1"

Reference: https://github.com/argoproj/argo-cd/blob/6e2f2c9d1e2339b3361f3a057747fcfe30e36f44/docs/operator-manual/application.yaml