简体   繁体   中英

Disable Spring Cloud Kubernetes in local

Small question on how to disable Spring Cloud Kube.netes in local mode please.

The project is a simple SpringBoot + SpringCloud project deployed in Kube.netes. Hence, there is this dependency in the class path:

        <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. However, the same app run in local mode will yield this warning, but most of all, a 20 seconds increased start time.

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?

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.

Create the file "bootstrap.properties" into the resources folder

Then add the following lines:

spring.cloud.kubernetes.enabled=false
spring.cloud.kubernetes.discovery.enabled=false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM