1

I have a set of applications I would like to deploy on several eks clusters like Prometheus, Grafana and others. I have this setup inside 1 git repo that has an app of apps that each cluster could reference to.

My issue is having small changes in the value for these deployments, lets say for the Grafana deployment I want a unique url per cluster:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: grafana
  namespace: argocd
spec:
  project: default
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
      - PrunePropagationPolicy=foreground
      - CreateNamespace=true
    retry:
      limit: 2
      backoff:
        duration: 5s
        maxDuration: 3m0s
        factor: 2
  destination:
    server: "https://kubernetes.default.svc"
    namespace: 
  source:
    repoURL: 
    targetRevision: 
    chart: 
    helm:
      releaseName: grafana
      values: |
        ...
        ...
         hostname/url: {cluster_name}.grafana....   <-----
        ...
        ...

so far the only way i see doing this is by having multiple values files, is there a way to make it read values from config maps or maybe pass down a variable through the app of apps to make this work?

any help is appreciated

Taimoor Mirza
  • 1,093
  • 7
  • 19

1 Answers1

0

I'm afraid there is no (yet) good generic solution for templating values.yaml for the Helm charts in the ArgoCD.

Still, for your exact case, ArgoCD already has all you need.

Your "I have a set of applications" should naturally bring you to the ApplicationSet Controller and its features.

For iteration over the set of clusters, I'd recommend you to look at ApplicationSet Generators and in particular on Cluster Generator. Then your example would look something like:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: 'grafana'
  namespace: 'argocd'
  finalizers:
    - 'resources-finalizer.argocd.argoproj.io'

spec:
  generators:
    - clusters:  # select only "remote" clusters
        selector:
          matchLabels:
            'argocd.argoproj.io/secret-type': 'cluster'

  template:
    metadata:
      name: 'grafana-{{ name }}'

    spec:
      project: 'default'
      destination:
        server: '{{ server }}'
        namespace: 'grafana'
      source:
        path: 
        repoURL: 
        targetRevision:
        releaseName: grafana
        helm:
          values: |
            ...
            ...
            hostname/url: {{ name }}.grafana....   <-----
            ...
            ...
      syncPolicy:
        automated:
          prune: true
          selfHeal: true
      syncOptions:
        - PrunePropagationPolicy=foreground
        - CreateNamespace=true
      retry:
        limit: 2
      backoff:
        duration: 5s
        maxDuration: 3m0s
        factor: 2

Also check full Application definition for examples how to override particular parameters through:

    ...
    helm:
      # Extra parameters to set (same as setting through values.yaml, but these take precedence)
      parameters:
      - name: "nginx-ingress.controller.service.annotations.external-dns\\.alpha\\.kubernetes\\.io/hostname"
        value: mydomain.example.com
      - name: "ingress.annotations.kubernetes\\.io/tls-acme"
        value: "true"
        forceString: true # ensures that value is treated as a string

      # Use the contents of files as parameters (uses Helm's --set-file)
      fileParameters:
      - name: config
        path: files/config.json

As well as a combination of the inline values with valueFiles: for common options.

Timur Bakeyev
  • 296
  • 4
  • 4