0

Trying to understand passing TLAs to my jsonnet file with argocd. This is part of my argocd application.yaml which compiles the kube-prometheus manifests straight from my main.jsonnet file. I want to create 2 kube-prometheus apps in argocd (prod and nonprod) and I want to pass TLAs to change the ingress host name suffix for each app instance.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: kube-prometheus-nonprod
  namespace: argocd
spec:
  destination:
    name: ''
    namespace: monitoring
    server: 'https://kubernetes.default.svc'
  source:
    path: kube-prometheus/src
    repoURL: 'https://myrepo.git'
    targetRevision: branch-name
    directory:
      jsonnet:
        tlas:
          - name: npDomainSuffix
            value: np.example.io
      libs:
        - kube-prometheus/vendor/

In my main.jsonnet file I have for example:

hosts: ['grafana.$(npDomainSuffix)']

New to jsonnet and argocd and can't get it to work. Can I use TLAs in this way?

Alan
  • 491
  • 4
  • 13

1 Answers1

2

If you're new to jsonnet, I'd recommend using extVars instead, as TLA mechanics are somewhat harder to grasp, from the jsonnet tutorial for the TLA section, you'll find that your jsonnet code needs an entry function with arguments named after each top-level-argument name.

Alternatively, using extVars you should be able to do instead:

        extVars:
          - name: npDomainSuffix
            value: np.example.io

then anywhere in your jsonnet code (extVars are global)

hosts: ['grafana.' + std.extVar('npDomainSuffix')]
jjo
  • 2,595
  • 1
  • 8
  • 16