bash 如何覆盖 helm 值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49223125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to override a helm value
提问by Marcos J.C Kichel
I am actually working on a development environment using Gradle, Docker, Minikube and Helm.
我实际上正在使用 Gradle、Docker、Minikube 和 Helm 开发一个开发环境。
I am using a bunch of bash scripts to get things done.
我正在使用一堆 bash 脚本来完成任务。
What I achieved so far is:
到目前为止我取得的成就是:
- Gradle builds the jar using a plugin for versioning.
- Gradle builds a docker image with the same version calculated on the jar job.
- Gradle 使用版本控制插件构建 jar。
- Gradle 使用在 jar 作业上计算出的相同版本构建一个 docker 镜像。
Now I need to be able to propagate the version calculated by Gradle to Helm so it can pick the right docker image.
现在我需要能够将 Gradle 计算的版本传播到 Helm,以便它可以选择正确的 docker 图像。
The approach I already have in mind is to define an environment variable so it can be used by Helm.
我已经想到的方法是定义一个环境变量,以便 Helm 可以使用它。
The problem is that I would need to redefine it afterward.
问题是我之后需要重新定义它。
Is any better way of doing that?
有没有更好的方法来做到这一点?
回答by Grant David Bachman
Most Helm charts contain at least the following in their values.yaml
file, which sets a default docker image tag, and also allows the user installing/upgrading the chart to specify a different image without having to modify the chart itself.
大多数 Helm 图表在其values.yaml
文件中至少包含以下内容,这些内容设置了默认的 docker 图像标签,并且还允许用户安装/升级图表以指定不同的图像,而无需修改图表本身。
# values.yaml
image:
repository: <docker-repo-url-here>
tag: <docker-image-tag-here>
And in the deployment yaml, fetch the values from the values.yaml
在部署 yaml 中,从 values.yaml 中获取值
# deployment.yaml
kind: Deployment
spec:
template:
spec:
containers:
- name: container-name
image: "{{ .Values.image.repository }}:{{ .Values.image.tag}}"
From there, you can do a simple helm upgrade <release-name> <chart-path> --set image.tag=<new-image-tag>
when you want to use a new image.
从那里,您可以helm upgrade <release-name> <chart-path> --set image.tag=<new-image-tag>
在想要使用新图像时做一个简单的事情。