arkade icon indicating copy to clipboard operation
arkade copied to clipboard

Supporting values files for helm charts

Open LucasRoesler opened this issue 2 years ago • 6 comments

Expected Behaviour

If an app is packaged via a helm chart, then arkade should support passing a values file, for example

arkade install openfaas --values=custom.yaml

Current Behaviour

Value file support is not indicated in the CLI help text

$ arkade install openfaas -h
Install openfaas

Usage:
  arkade install openfaas [flags]

Examples:
  arkade install openfaas --load-balancer

Flags:
  -a, --basic-auth                    Enable authentication (default true)
      --basic-auth-password string    Overide the default random basic-auth-password if this is set
      --clusterrole                   Create a ClusterRole for OpenFaaS instead of a limited scope Role
      --direct-functions              Invoke functions directly from the gateway, or load-balance via endpoint IPs when set to false
      --function-pull-policy string   Pull policy for functions (default "Always")
      --gateways int                  Replicas of gateway (default 1)
  -h, --help                          help for openfaas
      --ingress-operator              Get custom domains and Ingress records via the ingress-operator component
      --license-file string           Path to OpenFaaS Pro license file
  -l, --load-balancer                 Add a loadbalancer
      --log-provider-url string       Set a log provider url for OpenFaaS
      --max-inflight int              Max tasks for queue-worker to process in parallel (default 1)
  -n, --namespace string              The namespace for the core services (default "openfaas")
      --operator                      Create OpenFaaS Operator
      --pull-policy string            Pull policy for OpenFaaS core services (default "IfNotPresent")
      --queue-workers int             Replicas of queue-worker for HA (default 1)
      --set stringArray               Use custom flags or override existing flags 
                                      (example --set gateway.replicas=2)
      --update-repo                   Update the helm repo (default true)

Global Flags:
      --kubeconfig string   Local path for your kubeconfig file
      --wait                If we should wait for the resource to be ready before returning (helm3 only, default false)

Further, the README even suggests that this is a desirable feature https://github.com/alexellis/arkade#say-goodbye-to-valuesyaml-and-hello-to-flags

Are you a GitHub Sponsor (Yes/No?)

Check at https://github.com/sponsors/alexellis

  • [x] Yes
  • [ ] No

Possible Solution

Add a --values flag that is then passed to the helm internally.

Context

I am trying to create a walkthrough about using Loke, Tempo, and OpenFaaS together. But, there are just configurations I need to pass that are just too complex to want to parse and then pass as CLI flags via --set, for example, passing this configuration to Grafana

env:
  GF_AUTH_ANONYMOUS_ENABLED: true
  GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
  GF_AUTH_DISABLE_LOGIN_FORM: true

grafana.ini:
  server:
    domain: monitoring.openfaas.local
    root_url: "%(protocol)s://%(domain)s/grafana"
    serve_from_sub_path: true

datasources:
  datasources.yaml:
    apiVersion: 1

    datasources:
      - name: Tempo
        type: tempo
        access: proxy
        orgId: 1
        url: http://tempo:3100
        isDefault: false
        version: 1
        editable: false
        uid: tempo
      - name: Loki
        type: loki
        access: proxy
        url: http://loki:3100
        isDefault: true
        version: 1
        editable: false
        uid: loki
        jsonData:
          derivedFields:
            - datasourceUid: tempo
              matcherRegex: (?:traceID|trace_id|traceId|traceid=(\w+))
              url: "$${__value.raw}"
              name: TraceID

Additionally, there are sometimes a need to pass in special characters which are then captured and parsed incorrectly by arkade, preventing the installation of the app. For example, i wanted to setup the nginx log format to use the logfmt style, ie key=value style. The command i tried to use with arkade looks like this

arkade install ingress-nginx \
           --set controller.config.enable-opentracing='true' \
           --set controller.config.jaeger-collector-host=tempo.default.svc.cluster.local \
           --set controller.hostPort.enabled='true' \
           --set controller.service.type=NodePort \
           --set controller.service.nodePorts.http=30080 \
           --set controller.publishService.enabled='false' \
           --set controller.extraArgs.publish-status-address=localhost \
           --set controller.updateStrategy.rollingUpdate.maxSurge=0 \
           --set controller.updateStrategy.rollingUpdate.maxUnavailable=1 \
           --set controller.config.log-format-upstream='remote_addr=$remote_addr user=$remote_user ts=$time_local request="$request" status=$status body_bytes=$body_bytes_sent referer="$http_referer" user_agent="$http_user_agent" request_length=$request_length duration=$request_time upstream=$proxy_upstream_name upstream_addr=$upstream_addr upstream_resp_length=$upstream_response_length upstream_duration=$upstream_response_time upstream_status=$upstream_status traceId=$opentracing_context_uber_trace_id'

But this simply produces an error Error: incorrect format for custom flag. It is failing because of the equal signs in the log format string. This can be verified because this command succeeds

arkade install ingress-nginx \
           --set controller.config.enable-opentracing='true' \
           --set controller.config.jaeger-collector-host=tempo.default.svc.cluster.local \
           --set controller.hostPort.enabled='true' \
           --set controller.service.type=NodePort \
           --set controller.service.nodePorts.http=30080 \
           --set controller.publishService.enabled='false' \
           --set controller.extraArgs.publish-status-address=localhost \
           --set controller.updateStrategy.rollingUpdate.maxSurge=0 \
           --set controller.updateStrategy.rollingUpdate.maxUnavailable=1 \
           --set controller.config.log-format-upstream='$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] [$proxy_alternative_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id traceId $opentracing_context_uber_trace_id'

Your Environment

  • What Kubernetes distribution are you using?
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:59:11Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
  • Operating System and version (e.g. Linux, Windows, MacOS):
$ uname -a
Linux io-xps 5.13.0-21-generic #21-Ubuntu SMP Tue Oct 19 08:59:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 21.10"
NAME="Ubuntu"
VERSION_ID="21.10"
VERSION="21.10 (Impish Indri)"
VERSION_CODENAME=impish
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=impish
  • What arkade version is this?
$ arkade version
            _             _      
  __ _ _ __| | ____ _  __| | ___ 
 / _` | '__| |/ / _` |/ _` |/ _ \
| (_| | |  |   < (_| | (_| |  __/
 \__,_|_|  |_|\_\__,_|\__,_|\___|

Get Kubernetes apps the easy way

Version: 0.8.8
Git Commit: 10f4f5e0b2f5012b85a7a2b4b45a0aecdb4d8ea6

LucasRoesler avatar Nov 29 '21 13:11 LucasRoesler

Thanks for taking the time to write this up.

I am seeing two issues:

  1. A use-case with many embedded or complex values within one single chart
  2. A parsing error

Additionally, there are sometimes a need to pass in special characters which are then captured and parsed incorrectly by arkade, preventing the installation of the app. For example, i wanted to setup the nginx log format to use the logfmt style, ie key=value style. The command i tried to use with arkade looks like this

For 2) can you raise a separate issue?

For 1)

How likely are users going to be to edit all of the values you quoted? Many helm charts are jam packed with options like the openfaas chart, or the Kasten chart, however, oftentimes you only need to edit < 5 values to make it work in a good default way.

How many values do you feel users would need to change vs. your defaults in this new chart being created for the openfaas/tempo PoC?

alexellis avatar Nov 30 '21 09:11 alexellis

RE (1) this is impossible to say. I don't know what a user will want to edit because it depends on their situation.

In my case, I only wanted to do 3 things: (a) install some default data sources, (b) add tracing id as a derived field in Loki, and (c) change the URL configuration. This seems pretty reasonable, to me, if you are deploying the Grafana+Loki+Tempo stack together.

But I am sure there are other values that might need to be configured by other people. In my opinion, a value exists in a Helm chart because the author either decided should be configurable or it was requested to be configurable. My day job isn't installing and running Grafana for a lot of people, so I don't know what is "typical" for a real installation.

LucasRoesler avatar Nov 30 '21 10:11 LucasRoesler

RE (2) it is split to here https://github.com/alexellis/arkade/issues/592

LucasRoesler avatar Nov 30 '21 10:11 LucasRoesler

I'm not against values.yaml as a concept and use it some of the time for various projects. Especially when I have to change many things to install an app.

You say it's impossible to know what a sane default is for your chart. So what did you want to edit for your personal installation of your app? If a deep knowledge of a values file is the only way a chart is useful then it may not be a good fit for arkade.

The idea of arkade is to give sane defaults plus a few key overrides.

If you do still see value in this new chart that you're creating being an app in Arkade and it takes a values.yaml file, will this set a precedent for all other apps?

What about the apps that use a CLI installer or static YAML files?

alexellis avatar Dec 01 '21 12:12 alexellis

@bxffour

Could you please work on supporting a values.yaml file for arkade install openfaas?

We should be able to include a local YAML file in addition to any flags or overrides that are sent in via --set.

The current resulting command takes things like --loadbalancer and converts that to a Helm --set flag.

Any values.yaml files (this will need to be a string array) should be added as -f file.yaml to the same command.

For testing, show that:

  • --set
  • --values
  • and --gateways (a flag that's covnerted to --set`)

Are all inputted into the final Helm command.

Thanks and let me know if you have any questions.

alexellis avatar Jun 15 '23 08:06 alexellis

@bxffour

Could you please work on supporting a values.yaml file for arkade install openfaas?

We should be able to include a local YAML file in addition to any flags or overrides that are sent in via --set.

The current resulting command takes things like --loadbalancer and converts that to a Helm --set flag.

Any values.yaml files (this will need to be a string array) should be added as -f file.yaml to the same command.

For testing, show that:

  • --set
  • --values
  • and --gateways (a flag that's covnerted to --set`)

Are all inputted into the final Helm command.

Thanks and let me know if you have any questions.

I understand. I will look into this and let you know if I have any questions.

bxffour avatar Jun 15 '23 14:06 bxffour