[英]Spring Cloud Config Client Actuator Refresh
我有一个监听配置服务器的客户端。 Config Server 指向 github。 本地主机工作正常。 但是,当我将应用程序部署到 Kubernetes 时,刷新属性的客户端端点无法正常工作。
端点(发布): http://config-client.sbx.com/actuator/refresh
这将在 Postman "[]" 上返回一个空响应,并且响应代码为 200 OK。 我可以看到配置服务器已在 K8s 上启动并运行。
关于什么可能是错的任何建议?
PS 我启用了调试日志,但在那里看不到太多信息。
您能否在刷新时验证应用程序链接是否已获取主机名和应用程序名称。 因为在 localhost 中进行刷新时,它只是本地的 springboot 应用程序,因此不需要额外的 application-name 路径。 当您通常部署到服务器时,除了主机名之外,我们还必须提供应用程序的路径名。 在tomcat中,我使用的URL如下,
http://<hostname>/**<application-name>**/actuator/refresh/
通常,当您通过 postman 访问此 URL 时,它会给您一个 200 响应,其中的 [] 为空。 然后,您应该能够在客户端应用程序的日志文件中看到以下行。 [我还在应用程序的 main 方法中在 @SpringBootApplication 属性下方设置了属性@RefreshScope属性来刷新应用程序的属性。]
INFO o.s.c.c.c.ConfigServicePropertySourceLocator.getRemoteEnvironment:249 - Fetching config from server at : http://<hostname>/<Config-server-application-name>/
INFO o.s.c.c.c.ConfigServicePropertySourceLocator.log:168 - Located environment: name=config-client, profiles=[development], label=null, version=ab36989c85922f1c9cf7803fac4, state=null
INFO o.s.c.b.c.PropertySourceBootstrapConfiguration.initialize:112 - Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://<gitlaburl>/<companyname>/config-server.git/config-client-development.yml'}]
INFO o.s.boot.SpringApplication.logStartupProfileInfo:655 - The following profiles are active: development
INFO o.s.boot.SpringApplication.logStarted:61 - Started application in 1.557 seconds (JVM running for 70689.032)
对于 Kubernetes,
尝试使用
kubectl 应用
(而不是 kubectl 创建配置映射。)
要部署配置 map,只需在 Kubernetes 上运行以下命令:
kubectl apply -f config-map.yml
确保配置 map 的名称与 spring 启动应用程序的名称匹配。另请参见以下链接,
https://github.com/spring-cloud/spring-cloud-kubernetes/issues/255
还有一个 spring 云 kuberenetes,您可以如下探索,
我的客户端中有application.properties
和bootstrap.properties
文件。 在这种情况下,您应该在 bootstrap.yml 中指定spring.application.name
和spring.cloud.config.server.git.uri
。 我没有刷新applicaiton.properties
内具有spring.application.name
的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.