Reload namespace and label filtering
默认情况下,将使用 Namespace resolution 中概述的步骤选择的命名空间来监听 configmap 和 Secrets 中的更改。即:如果您不告诉 Reload 要监视哪些命名空间和 configmap/Secrets,它将监视使用上述算法计算出的命名空间中的所有 configmap/Secrets。
By default, a namespace chosen using the steps outlined in Namespace resolution will be used to listen to changes in configmaps and secrets. i.e.: if you do not tell reload what namespaces and configmaps/secrets to watch for, it will watch all configmaps/secrets from the namespace that will be computed using the above algorithm.
另一方面,您可以定义更细粒度的做法。例如,您可以指定将监视更改的命名空间:
On the other hand, you can define a more fine-grained approach. For example, you can specify the namespaces where changes will be monitored:
spring:
application:
name: event-reload
cloud:
kubernetes:
reload:
enabled: true
strategy: shutdown
mode: event
namespaces:
- my-namespace
此类配置将使应用程序仅在 my-namespace
命名空间中监视更改。请注意,这将监视 所有 ConfigMap/secret(具体取决于您启用的哪个)。如果您想要更细粒度的做法,您可以启用“标签筛选”。首先,我们需要通过 enable-reload-filtering: true
启用此类支持
Such a configuration will make the app watch changes only in the my-namespace
namespace. Mind that this will
watch all configmaps/secrets (depending on which one you enable). If you want an even more fine-grained approach,
you can enable "label-filtering". First we need to enable such support via : enable-reload-filtering: true
spring:
application:
name: event-reload
cloud:
kubernetes:
reload:
enabled: true
strategy: shutdown
mode: event
namespaces:
- my-namespaces
monitoring-config-maps: true
enable-reload-filtering: true
这将监视仅具有 spring.cloud.kubernetes.config.informer.enabled: true
标签的 ConfigMap/secret。
What this will do, is watch configmaps/secrets that only have the spring.cloud.kubernetes.config.informer.enabled: true
label.
Name | Type | Default | Description |
---|---|---|---|
|
|
|
Enables monitoring of property sources and configuration reload |
|
|
|
Allow monitoring changes in config maps |
|
|
|
Allow monitoring changes in secrets |
|
|
|
The strategy to use when firing a reload ( |
|
|
|
Specifies how to listen for changes in property sources ( |
|
|
|
The period for verifying changes when using the |
|
|
namespaces where we should watch for changes |
|
|
|
enabled labeled filtering for reload functionality |
备注:
Notes:
-
You should not use properties under
spring.cloud.kubernetes.reload
in config maps or secrets. Changing such properties at runtime may lead to unexpected results. -
Deleting a property or the whole config map does not restore the original state of the beans when you use the
refresh
level.