diff --git a/README.adoc b/README.adoc index c95c59b6..f770bfbe 100644 --- a/README.adoc +++ b/README.adoc @@ -1202,6 +1202,57 @@ You can configure the polling period by using the `spring.cloud.kubernetes.reloa It requires the same role as the monitored property source. This means, for example, that using polling on file-mounted secret sources does not require particular privileges. +[[namespace-label-filtering]] +=== Reload namespace and label filtering +By default, a namespace chosen using the steps outlined in <> 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: + +==== +[source,yaml] +---- +spring: + application: + name: event-reload + cloud: + kubernetes: + reload: + enabled: true + strategy: shutdown + mode: event + namespaces: + - my-namespace +---- +==== + +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` + +==== +[source,yaml] +---- +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 +---- +==== + +What this will do, is watch configmaps/secrets that only have the `spring.cloud.kubernetes.config.informer.enabled: true` label. + .Properties: [options="header,footer"] |=== @@ -1209,9 +1260,11 @@ This means, for example, that using polling on file-mounted secret sources does | `spring.cloud.kubernetes.reload.enabled` | `Boolean` | `false` | Enables monitoring of property sources and configuration reload | `spring.cloud.kubernetes.reload.monitoring-config-maps` | `Boolean` | `true` | Allow monitoring changes in config maps | `spring.cloud.kubernetes.reload.monitoring-secrets` | `Boolean` | `false` | Allow monitoring changes in secrets -| `spring.cloud.kubernetes.reload.strategy` | `Enum` | `refresh` | The strategy to use when firing a reload (`refresh`, `restart_context`, or `shutdown`) +| `spring.cloud.kubernetes.reload.strategy` | `Enum` | `refresh` | The strategy to use when firing a reload (`refresh`, `restart_context`, or `shutdown`) | `spring.cloud.kubernetes.reload.mode` | `Enum` | `event` | Specifies how to listen for changes in property sources (`event` or `polling`) | `spring.cloud.kubernetes.reload.period` | `Duration`| `15s` | The period for verifying changes when using the `polling` strategy +| `spring.cloud.kubernetes.reload.namespaces` | `String[]`| | namespaces where we should watch for changes +| `spring.cloud.kubernetes.reload.enable-reload-filtering` | `String` | | enabled labeled filtering for reload functionality |=== Notes: diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc index 26ad8215..76b149db 100644 --- a/docs/src/main/asciidoc/_configprops.adoc +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -90,11 +90,13 @@ |spring.cloud.kubernetes.loadbalancer.enabled | `+++true+++` | Load balancer enabled,default true. |spring.cloud.kubernetes.loadbalancer.mode | | {@link KubernetesLoadBalancerMode} setting load balancer server list with ip of pod or service name. default value is POD. |spring.cloud.kubernetes.loadbalancer.port-name | `+++http+++` | service port name. +|spring.cloud.kubernetes.reload.enable-reload-filtering | `+++false+++` | create an informer only for sources that have 'spring.cloud.kubernetes.config.informer.enabled=true' label. This property is only relevant for event based reloading. |spring.cloud.kubernetes.reload.enabled | `+++false+++` | Enables the Kubernetes configuration reload on change. |spring.cloud.kubernetes.reload.max-wait-for-restart | `+++2s+++` | If Restart or Shutdown strategies are used, Spring Cloud Kubernetes waits a random amount of time before restarting. This is done in order to avoid having all instances of the same application restart at the same time. This property configures the maximum of amount of wait time from the moment the signal is received that a restart is needed until the moment the restart is actually triggered |spring.cloud.kubernetes.reload.mode | | Sets the detection mode for Kubernetes configuration reload. |spring.cloud.kubernetes.reload.monitoring-config-maps | `+++true+++` | Enables monitoring on config maps to detect changes. |spring.cloud.kubernetes.reload.monitoring-secrets | `+++false+++` | Enables monitoring on secrets to detect changes. +|spring.cloud.kubernetes.reload.namespaces | | namespaces where an informer will be set-up. this property is only relevant for event based reloading. |spring.cloud.kubernetes.reload.period | `+++15000ms+++` | Sets the polling period to use when the detection mode is POLLING. |spring.cloud.kubernetes.reload.strategy | | Sets reload strategy for Kubernetes configuration reload on change. |spring.cloud.kubernetes.secrets.enable-api | `+++false+++` |