Helm在本地导出YAML文件(仅使用模板引擎,不发送到Kubernetes)

pvcm50d1  于 2022-12-11  发布在  Kubernetes
关注(0)|答案(5)|浏览(479)

我想把已经模板化的Helm图表导出为YAML文件。我现在不能在我的Kubernetes集群上使用Tiller,但是我仍然想使用Helm图表。基本上,我想让Helm导出YAML,然后把它发送到Kubernetes API,其中的值是Helm模板化的。之后,我会把YAML文件上传到我的Kubernetes集群。
我尝试运行.\helm.exe install --debug --dry-run incubator\kafka,但得到错误Error: Unauthorized
请注意,我在Windows上运行Helm(版本helm-v2.9.1-windows-amd 64)。

6rvt4ljy

6rvt4ljy1#

我们需要日志来检查Unauthorized问题。
但是您可以轻松地在本地生成模板:

helm template mychart

在本地呈现图表模板并显示输出。
这不需要Tiller。但是,通常在集群中查找或检索的任何值都将在本地伪造。此外,不会进行任何服务器端的图表有效性测试(例如,是否支持API)。
更多信息:https://helm.sh/docs/helm/helm_template/

ccrfmcuu

ccrfmcuu2#

Amrit Bera的解决方案将只与本地舵图工作,根据您的问题的细节,你希望它与远程舵图工作,这是一个功能,将被添加到Helm v3(目前正在进行中).
RehanSaeed发布了以下解决方法(https://github.com/helm/helm/issues/4527
基本上:

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

好的一面是你可以把这个技术和weaveworks flux结合起来使用git ops +,这给了你另一个选择,除了Tiller插件(它可以让你在本地运行Tiller,但是运行起来不太流畅)之外,你还可以使用没有Tiller的Helm v2。

yizd12fk

yizd12fk3#

直接从helm install --help

To check the generated manifests of a release without installing the chart,
the '--debug' and '--dry-run' flags can be combined. This will still require a
round-trip to the Tiller server.
4si2a6ki

4si2a6ki4#

If you want to see only the resolved YAML you can use

helm template .

I prefer to see it on a file

helm template . > solved.yaml
ukqbszuj

ukqbszuj5#

This is not the answer for the question but this post on stackoverflow is the first one which was displayed in searchengines when i was searching for a solution of my problem and solved it by myself reading the Helm CLI docs. I post it here anyway because maybe someone else is searching for the same usecase as i did.
For already installed Helm charts on a Kubernetes cluster you can use the following command to export/download all information for a named release:

helm get all <release-name>

or

helm get all <release-name> > installed-kubernetes-resources.yaml

If you only want e.g. the manifests or values instead of all, just replace the all command appropriately (get more details by using helm get --help ):

Usage:
  helm get [command]

Available Commands:
  all         download all information for a named release
  hooks       download all hooks for a named release
  manifest    download the manifest for a named release
  notes       download the notes for a named release
  values      download the values file for a named release

If you want to export the information for a named release with a distinct revision you can use the flag --revision int in your get command ( helm get all --help ). To list all possible revisions of your named release just use the command helm history <release-name> .
My Helm CLI version: version.BuildInfo{Version:"v3.5.0", GitCommit:"32c22239423b3b4ba6706d450bd044baffdcf9e6", GitTreeState:"clean", GoVersion:"go1.15.6"}

相关问题