每当我运行基本的deploy命令时,一切都将重新部署到我的环境中。有什么办法告诉Helm仅在进行更改时才应用这些东西,或者这仅仅是它的工作方式?
我正在跑步:
helm upgrade --atomic MyInstall . -f CustomEnvironmentData.yaml
在Helm Upgrade documentation中没有看到任何似乎表明该功能的东西。
除非有必要,否则我不想退缩整个环境。
答案 0 :(得分:3)
无法告诉Helm做到这一点,但也没有必要。如果您向Kubernetes API服务器提交与已经存在的对象完全匹配的对象,通常不会发生任何事情。
例如,假设您有一个Deployment对象,该对象指定image: my/image:{{ .Values.tag }}
和replicas: 3
。您使用tag: 20200904.01
提交一次。现在,您运行显示的helm upgrade
命令,而tag
文件中的CustomEnvironmentData.yaml
值保持不变。实际上,这将触发Kubernetes内部的部署控制器。这样可以看到它与图像my/image:20200904.01
存在3个容器。这三个吊舱已经存在,所以它什么也不做。
(这与“请勿使用latest
标签”建议基本相同:如果您尝试设置image: my/image:latest
,并使用此标签重新部署,因为Deployment规范是不变的Kubernetes不会做任何事情,即使注册表中映像的版本已更改。)
答案 1 :(得分:1)
您可能应该使用helm diff upgrade
https://github.com/databus23/helm-diff
$ helm diff upgrade - h
Show a diff explaining what a helm upgrade would change.
This fetches the currently deployed version of a release
and compares it to a chart plus values.
This can be used visualize what changes a helm upgrade will
perform.
Usage:
diff upgrade[flags] [RELEASE] [CHART]
Examples:
helm diff upgrade my-release stable / postgresql--values values.yaml
Flags:
-h, --help help for upgrade
--detailed - exitcode return a non - zero exit code when there are changes
--post - renderer string the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path
--reset - values reset the values to the ones built into the chart and merge in any new values
--reuse - values reuse the last release's values and merge in any new values
--set stringArray set values on the command line(can specify multiple or separate values with commas: key1 = val1, key2 = val2)
--suppress stringArray allows suppression of the values listed in the diff output
- q, --suppress - secrets suppress secrets in the output
- f, --values valueFiles specify values in a YAML file(can specify multiple)(default[])
--version string specify the exact chart version to use.If this is not specified, the latest version is used
Global Flags:
--no - color remove colors from the output