k3s-io/helm-controller

Any --set-file option in HelmChart Resource?

kenho811 opened this issue ยท 6 comments

Hi,

The Helm CLI has the option to pass file content to the values.yaml via the flag --set-file.

Screenshot_20230210_140711_Chrome.jpg

Ref:
https://v2.helm.sh/docs/using_helm/#the-format-and-limitations-of-set

Can we do something like this below using k3s's HelmChart resource?


apiVersion: helm.cattle.io/v1 
kind: HelmChart
metadata: 
  name: example-helmchart namespace: kube-system

 spec: 
   chart: test-helmchart     
  targetNamespace: test-namespace version: 0.0.1
  repo: https://example.com/helm-charts 
set: 
key1: "value1"
 key2: "value2" 
set-file:
 key3: "path-to-file"


(Sorry about the formatting. Was typing using my mobile phone)

I am mainly interested in the set-file section above.

Thank you ;))

That is exactly what the ValuesContent field does, on both the HelmChart and HelmChartConfig resources.

I see.

But with ValuesContent, I cannot refer to a value which resides in a file via file path (outside the HelmChart resource)?

Say if I want to refer to an external file containing a value to be used in two different HelmChart resources. Then I need to duplicate the values in the two HelmChart resources?

Actually, I see that you're asking to use --set-file, which pulls in a single key's value from a file. No, there is not any way to do that. Using the --values option to set all the keys from yaml is definitely more efficient than using set, though, given that you can provide structured content.

https://docs.k3s.io/helm#helmchart-field-definitions

Note that each HelmChart is processed in an isolated job pod, with only access to the chart and its values files (if any), so trying to reference values from additional external files wouldn't get you much.

The ability to inject value content from external things like configmaps or secrets is interesting though, definitely something to think about.

That's a great idea.

Perhaps the Job Container which runs the Helm command can read from a ConfigMap.

And then I can generate the ConfigMap dynamically with kustomize's ConfigMapGenerator, which refers to a file.