6

I looked all over the ArgoCD docs for this but somehow I cannot seem to find an answer. I have an application spec like so:

apiVersion: argoproj.io/v1alpha1                                                                                                                                                                                                                                                          
kind: Application                                                                                                                                                                                                                                                                         
metadata:                                                                                                                                                                                                                                                                                 
  name: myapp                                                                                                                                                                                                                                                                            
  namespace: argocd                                                                                                                                                                                                                                                                       
spec:                                                                                                                                                                                                                                                                                     
  destination:                                                                                                                                                                                                                                                                            
    namespace: default                                                                                                                                                                                                                                                                    
    server: https://kubernetes.default.svc                                                                                                                                                                                                                                                
  project: default                                                                                                                                                                                                                                                                        
  source:                                                                                                                                                                                                                                                                                 
    helm:                                                                                                                                                                                                                                                                                 
      valueFiles:                                                                                                                                                                                                                                                                         
      - my-values.yaml                                                                                                                                                                                                                                                     
    path: .                                                                                                                                                                                                                                        
    repoURL: ssh://git@blah.git                                                                                                                                                                                                                        
    targetRevision: HEAD

However, I also need to specify a particular helm value (like you'd do with --set in the helm command. I see in the ArgoCD web UI that it has a spot for Values, but I have tried every combination of entries I can think of (somekey=somevalue, somekey:somevalue, somekey,somevalue). I also tried editing the manifest directly, but I still get similar errors trying to do so. ArgoCD Web UI The error is long nonsense that ends with error unmarshaling JSON: while decoding JSON: json: cannot unmarshal string into Go value of type map[string]interface {}

What is the correct syntax to set a single value, either through the web UI or the manifest file?

tubensandwich
  • 128
  • 1
  • 1
  • 7

2 Answers2

7

To override just a few arbitrary parameters in the values you indeed can use parameters: as the equivalent of Helm's --set option or fileParameters: instead of --set-file:

...
    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

But to answer your original question, for the "Values" option in the GUI you pass literal YAML block in the manifest, like:

    helm:
      # Helm values files for overriding values in the helm chart
      # The path is relative to the spec.source.path directory defined above
      valueFiles:
      - values-prod.yaml

      # Values file as block file
      values: |
        ingress:
          enabled: true
          path: /
          hosts:
            - mydomain.example.com
          annotations:
            kubernetes.io/ingress.class: nginx
            kubernetes.io/tls-acme: "true"
          labels: {}

Check ArgoCD sample application for more details.

Timur Bakeyev
  • 296
  • 4
  • 4
4

you would use parameters via spec.source.helm.parameters

something like:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  project: my-project
  source:
    repoURL: https://charts.my-company.com
    targetRevision: "1234"
    chart: my-chart
    helm:
      parameters:
        - name: my.helm.key
          value: some-val
  destination:
    name: k8s-dev
    namespace: my-ns

Sample from Argo Docs - https://argo-cd.readthedocs.io/en/stable/user-guide/helm/#build-environment

LostJon
  • 2,287
  • 11
  • 20
  • Thank you. Do you happen to know what the 'VALUES' box would be for in the screenshot above then? – tubensandwich Jul 28 '22 at 20:42
  • Values is the inline values you can pass in, and valuesFiles is the yml values files that live next to the chart when it's published. – LostJon Jul 30 '22 at 12:57
  • So how do values differ from parameters? – tubensandwich Jul 31 '22 at 15:03
  • 2
    values has less priority than `parameters`. parameters mimics `--set` option from a `helm` command, where as `values` is like another `valuesFile`. – LostJon Aug 01 '22 at 14:04
  • Okay, thanks. So it's just the content you'd normally put in a values file, but inline. For some reason that didn't register when I read your last comment, my apologies. I actually also needed to set up grabbing values files from external repos recently, which helped me understand this a bit more. I was following [this guide](https://softrams.com/insights/external-value-files-in-argo-cd-with-applicationsets/), in which you can grab the content from external values files and use them as the content for `values`. Thanks again. – tubensandwich Aug 01 '22 at 22:32