Kubernetes 集群中的 SpringBoot 服务如何知道计数器服务地址更改?
How a SpringBoot service in Kubernetes cluster knows about counter services address changing?
我在 Kubernetes 集群中有一堆应用程序,它们相互连接,比如 SpringBoot 应用程序连接到 RabbitMQ。它们都在容器中。
通常独立的 SpringBoot 应用程序从 application.yaml/bootstrap.yaml 读取配置,但据我所知,在 Kubernetes 集群的情况下,它从 ConfigMap 读取配置,并且计数器服务的地址应该存储在那里(是吗?)
所以问题是:如果 RabbitMQ pod 重新部署(例如失败并重新启动),如何触发 SpringBoot 以重新读取新配置?谁触发的?什么时候?
Spring cloud kubernetes has proertysource reload feature and is able to trigger an application reload when a related ConfigMap or Secret changes. So if rabbitmq endpoint changes you can update the configMap and application will reload automatically and pick up the new config. But in a real production scenario you will have a stable endpoint for rabbitmq exposed via kubernetes services。即使 pod IP 可能会更改服务 IP 或 DNS 也将保持不变。
rabbitmq 应部署为 StatefulSet,提供 table,唯一的网络标识符。
我在 Kubernetes 集群中有一堆应用程序,它们相互连接,比如 SpringBoot 应用程序连接到 RabbitMQ。它们都在容器中。
通常独立的 SpringBoot 应用程序从 application.yaml/bootstrap.yaml 读取配置,但据我所知,在 Kubernetes 集群的情况下,它从 ConfigMap 读取配置,并且计数器服务的地址应该存储在那里(是吗?)
所以问题是:如果 RabbitMQ pod 重新部署(例如失败并重新启动),如何触发 SpringBoot 以重新读取新配置?谁触发的?什么时候?
Spring cloud kubernetes has proertysource reload feature and is able to trigger an application reload when a related ConfigMap or Secret changes. So if rabbitmq endpoint changes you can update the configMap and application will reload automatically and pick up the new config. But in a real production scenario you will have a stable endpoint for rabbitmq exposed via kubernetes services。即使 pod IP 可能会更改服务 IP 或 DNS 也将保持不变。
rabbitmq 应部署为 StatefulSet,提供 table,唯一的网络标识符。