Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Helm export YAML files locally (just use templating engine, do not send to Kubernetes)

I want to export already templated Helm Charts as YAML files. I can not use Tiller on my Kubernetes Cluster at the moment, but still want to make use of Helm Charts. Basically, I want Helm to export the YAML that gets send to the Kubernetes API with values that have been templated by Helm. After that, I will upload the YAML files to my Kubernetes cluster.

I tried to run .\helm.exe install --debug --dry-run incubator\kafka but I get the error Error: Unauthorized.

Note that I run Helm on Windows (version helm-v2.9.1-windows-amd64).

like image 897
j9dy Avatar asked May 29 '18 12:05

j9dy


People also ask

How do I get YAML from Helm chart?

In helm, there is a command called helm template . Using the template command you can convert any helm chart to a YAML manifest. The resultant manifest file will have all the default values set in the helm values. yaml.

Which tool generates Kubernetes YAML files from templates?

Kustomize is a command-line tool that can create and transform YAML files — just like yq .

What templating engine does Helm use?

While there're a lot of tools to template Kubernetes YAML files, Helm caught a lot of attention very early on and established itself as the market leader. Helm is a convenient templating engine: it uses the Go templating engine and the helpers from the Sprig library.


2 Answers

We need logs to check the Unauthorized issue.

But you can easily generate templates locally:

helm template mychart 

Render chart templates locally and display the output.

This does not require Tiller. However, any values that would normally be looked up or retrieved in-cluster will be faked locally. Additionally, none of the server-side testing of chart validity (e.g. whether an API is supported) is done.

More info: https://helm.sh/docs/helm/helm_template/

like image 59
Amrit Bera Avatar answered Oct 10 '22 01:10

Amrit Bera


Amrit Bera's solution will only work with local helm chart, per the details of your question you want it to work with remote helm chart, that's a feature that will be added to Helm v3 (Work in Progress currently).

RehanSaeed posted the following workaround (https://github.com/helm/helm/issues/4527)

Basically:

mkdir yamls helm fetch --untar --untardir . 'stable/redis' #makes a directory called redis  helm template --output-dir './yamls' './redis' #redis dir (local helm chart), export to yamls dir 

The good thing about this is you can mix this technique with weaveworks flux for git ops + this gives you another option for using Helm v2 without tiller, in addition to the Tiller Plugin (which lets you run tiller locally, but doesn't work smoothly).

like image 24
neokyle Avatar answered Oct 10 '22 01:10

neokyle