travisghansen / argo-cd-helmfile

Integration between argo-cd and helmfile
MIT License
223 stars 55 forks source link

Not clear where to set environment variables #3

Closed abdennour closed 4 years ago

abdennour commented 4 years ago

Hello and thank you for this initiative : argocd for helmfile. I followed the documentation. I got confused where to put env vars.

Using argoCD UI, I put them under "external vars":

image

When i checked the alternative YAML , i found them under jsonnet:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: mysql-admin-ui
spec:
  destination:
    name: ''
    namespace: ''
    server: 'https://kubernetes.default.svc'
  source:
    path: phpmyadmin
    repoURL: 'git@blah/blah/balh.git'
    targetRevision: HEAD
    directory:
      jsonnet:
        extVars:
          - name: HELMFILE_GLOBAL_OPTIONS
            value: '"-e prod -l name=mysql-admin-ui"'
            code: true
        tlas: []
  project: default
  syncPolicy:
    automated: null

And if i put them under "TOP-LEVEL ARGUMENTS", i found them in yaml under spec.source.directory.tlas.

Please what is the right place to put env vars of this plugin ?

travisghansen commented 4 years ago

I'm guessing when you created the project you must have selected the wrong plugin. The UI can be a bit confusing (or at least was, I haven't updated argo-cd in a while) about how to select this.

In the spec it's here:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  ...
spec:
  ...
  source:
    ...
    plugin:
      name: helmfile
      env:
      - name: HELMFILE_GLOBAL_OPTIONS
        value: --selector name!=kapacitor,name!=elasticsearch,name!=elasticsearch-curator

I'll update argo-cd to the latest to see if they've cleaned the UI up a bit.

abdennour commented 4 years ago

The syntax is correct. But new error appears:

Unable to create application: application spec is invalid: InvalidSpecError: Unable to generate manifests in <App-name>: rpc error: code = Unknown desc = exec: "argo-cd-helmfile.sh": executable file not found in $PATH

image

travisghansen commented 4 years ago

Are you deploying argo-cd itself via helm? You need to be sure to download the script from this project to make it available to argo-cd for execution.

travisghansen commented 4 years ago

Here's a snippet of values.yaml for the argocd deploy itself:

repoServer:
  ## Use init containers to configure custom tooling
  ## https://argoproj.github.io/argo-cd/operator-manual/custom_tools/
  ## When using the volumes & volumeMounts section bellow, please comment out those above.
  volumes:
  - name: custom-tools
    emptyDir: {}

  initContainers:
  - name: download-tools
    #image: alpine:3.12
    image: debian:sid-slim
    command: [sh, -c]
    args:
      - apt-get update && apt-get install -y curl wget &&
        curl -o /custom-tools/argo-cd-helmfile.sh https://raw.githubusercontent.com/travisghansen/argo-cd-helmfile/master/src/argo-cd-helmfile.sh &&
        chmod +x /custom-tools/argo-cd-helmfile.sh &&
        wget -qO /custom-tools/helmfile https://github.com/roboll/helmfile/releases/download/v0.130.0/helmfile_linux_amd64 &&
        chmod +x /custom-tools/helmfile &&
        wget -qO- https://get.helm.sh/helm-v3.3.4-linux-amd64.tar.gz | tar -xvzf - &&
        mv linux-amd64/helm /custom-tools/helm-v3 &&
        wget -qO- https://get.helm.sh/helm-v2.16.12-linux-amd64.tar.gz | tar -xvzf - &&
        mv linux-amd64/helm /custom-tools/helm-v2
    volumeMounts:
      - mountPath: /custom-tools
        name: custom-tools
  volumeMounts:
  - mountPath: /usr/local/bin/argo-cd-helmfile.sh
    name: custom-tools
    subPath: argo-cd-helmfile.sh
  - mountPath: /usr/local/bin/helmfile
    name: custom-tools
    subPath: helmfile
  - mountPath: /usr/local/bin/helm-v3
    name: custom-tools
    subPath: helm-v3
  - mountPath: /usr/local/bin/helm-v2
    name: custom-tools
    subPath: helm-v2
abdennour commented 3 years ago

Thank you @travisghansen . This is awesome