更新安装的机密时自动刷新 PODs,但它看起来没有发生

Refreshing PODs automatically when mounted secrets gets updated, but it looks not happening

我们正在为 DB 创建机密并将它们作为卷安装到 POD,但是当我们更新 pod 时不会刷新以获取新的更改。但文档说它确实会自动刷新

https://kubernetes.io/docs/concepts/configuration/secret/

我们在这里遗漏了什么吗?它是否需要代码方面的任何特定逻辑。

提前致谢

Kubernetes 本身目前不支持此功能,并且正在开发中 (https://github.com/kubernetes/kubernetes/issues/22368)。

您可以使用可用的自定义解决方案来实现相同的效果,其中一种流行的解决方案包括 Reloader

您链接的文档描述了当您更新 Kubernetes Secret 对象时,安装卷内的秘密值将得到更新。 Pod 内的应用程序 运行 在更新秘密后需要重新读取秘密,并且在更新秘密本身时不会创建新的 Pod。

另外,请注意,在实际更新密钥和将这些值反映在卷中之间可能会有一些延迟。

As a result, the total delay from the moment when the Secret is updated to the moment when new keys are projected to the Pod can be as long as the kubelet sync period + cache propagation delay, where the cache propagation delay depends on the chosen cache type (it equals to watch propagation delay, ttl of cache, or zero correspondingly)