在不改变现有应用程序行为的情况下,在 Kubernetes 中使用应用程序部署 ConfigMap 更改的典型策略是什么?

What is a typical strategy for deploying ConfigMap changes with app in Kubernetes without changing behaviour of existing app?

我有一个更新的应用程序要部署到 Kubernetes,其中包含 ConfigMap 中的新映像和修改后的配置。配置可能是更新后的值、已删除的内容或全新的配置密钥。

我的问题是,我应该如何隔离对新版本的更改而不将配置应用于任何现有版本?

我读过有关不可变配置映射的信息,这对我来说建议在每次部署或每次配置更改时创建一个新的 ConfigMap 是一个可能的选择。我不确定它们是否打算以这种方式使用。或者一旦没有其他人使用它,如何最好地安全地删除它。

此外,如何保证配置在 pods 滚动更新开始之前可用?

如果您对部署的每次修订都将应用一些自定义配置,那么在 separate/new ConfigMap 中使用它是正确的方法。

您可以考虑使用 helm chart which are simply yaml files combined into single package. It is easy to version them and share with other because once done right they goal is to be reusable. This means that common parts of the manifest can be changed in values without rewriting the templates. Helm has the native capability of rolling back a release 将您的应用程序部署到任何以前的 revision.

根据您的需要和用例,Kustomize 可以选择生成名为 generatorOptions

的新 ConfigMap 或 Secret