roboll / helmfile

Deploy Kubernetes Helm Charts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduce State Values(Environment Values + Defaulting)

mumoshu opened this issue · comments

This is a copy-paste of #361 (comment) for visibility.


We're going to introduce State Values, that should be the foundation for various useful features.

(Note that this isn't a breaking change)


We have a feature request that breaks .Environment.Values if done straightforward #398 (comment)

Alternatively, we can change the term to State Values, and:

  • Make it accessible in the template with .Values(not .Environment.Values)

  • Explicitly note in the documentation that Environment Values is for overriding (State) Values

  • Deprecate .Environment.Values and recommend using .Values.

  • .Values can be overrode with command-line args and environment values files(#398 (comment))

    # Internally this is an alias of `environments.default.values`
    values:
    - myAPIEndpoint: https://dev.example.com/
       mykey: myvalue
    
    environments:
      production:
        values:
        - myAPIEndpoint: https://prod.example.com/
    

    When --environment production

    • {{ .Environment.Values.mykey }} fails(This preserves the existing behavior)
    • {{ .Values.mykey }} results in myvalue cuz .Values is environments.default.values + environments.production.values
  • It's .Values so the command-line args to set it from k-v pairs would naturally look like helmfile --set KEY=VALUE

  • The command-line args to set it from a file it looks like helmfile --values FILE

  • We recently implemented #622 but it should be changed. Use helmfiles[].values rather than helmfiles[].environment.values make it similar to its command-line flag variant --values.

    helmfiles:
    - name: sub.helmfile.yaml
      values:
        mykey: myvalue
    
  • helmfile --environment NAME remains as-is. It set's the state's environment name.

  • helmfile --set-envvar NAME=VALUE, helmfile --envvar-set, or helmfile --envvar sets envvars from NAME=VALUE pairs.

  • helmfile --envvars-file FILE, or helmfile --envvars FILE sets environment variables from the FILE

For envvars, I personally prefer the combo of helmfile --envvars-file FILE and helmfile --envvar-set NAME=VALUE, as it seems user-friendly because (1)they naturally collocate in the flags list thati s alphabetically sorted (2) it's harder to confuse with --environment NAME.

helmfile --values FILE has been implemented as helmfile --state-values-file FILE and helmfile --set key=val as helmfile --state-values-file-set to avoid collision with the existing --values FILE flag of helmfile sync. See #644

values: is being added to the state file syntax and .Values is being added to the template syntax via #647

Please file another feature requests for adding helmfile ability to set envvars via command-line flags.