[英]Disable Spring Cloud Kubernetes in local
Small question on how to disable Spring Cloud Kube.netes in local mode please.关于如何在本地模式下禁用 Spring Cloud Kube.netes 的小问题。
The project is a simple SpringBoot + SpringCloud project deployed in Kube.netes.该项目是部署在Kube.netes中的一个简单的SpringBoot + SpringCloud项目。 Hence, there is this dependency in the class path:因此,在 class 路径中存在此依赖项:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-fabric8</artifactId>
</dependency>
And when we deployed the app in a Kube.netes environment, everything is fine.当我们在 Kube.netes 环境中部署应用程序时,一切都很好。 However, the same app run in local mode will yield this warning, but most of all, a 20 seconds increased start time.但是,在本地模式下运行的同一应用程序会产生此警告,但最重要的是,启动时间会增加 20 秒。
o.s.c.k.f.Fabric8AutoConfiguration : No namespace has been detected. Please specify KUBERNETES_NAMESPACE env var, or use a later kubernetes version (1.3 or later)
In local, while removing the dependency entirely, things are "back to normal".在本地,在完全消除依赖性的同时,一切都“恢复正常”。 The message disappears, and the start up time comes back down.消息消失,启动时间恢复。
However, commenting and uncommenting the dependency based on the local environment might not be the best solution.但是,根据本地环境对依赖项进行注释和取消注释可能不是最佳解决方案。
Is there a property to disable Spring Cloud Kube.netes entirely that I can configure in local please?是否有可以在本地配置的完全禁用 Spring Cloud Kube.netes的属性?
Thank you谢谢
As the documentation says , you can do that by adding:正如文档所说,您可以通过添加:
spring.cloud.kubernetes.enabled=false
that, in turn, could be an environment property that you can enable/disable per environment.反过来,它可能是一个环境属性,您可以根据环境启用/禁用它。
What worked for me was adding the spring.cloud.kubernetes.enabled=false
property in the boostrap.properties/yaml
file and not in the application.properties/yaml
file.对我有用的是在boostrap.properties/yaml
文件中而不是在application.properties/yaml
文件中添加spring.cloud.kubernetes.enabled=false
属性。
Create the file "bootstrap.properties" into the resources folder在资源文件夹中创建文件“bootstrap.properties”
Then add the following lines:然后添加以下行:
spring.cloud.kubernetes.enabled=false
spring.cloud.kubernetes.discovery.enabled=false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.