Disable Spring Cloud Kubernetes in local

1/25/2021

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

The project is a simple SpringBoot + SpringCloud project deployed in Kubernetes. 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 Kubernetes 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 Kubernetes entirely that I can configure in local please?

Thank you

-- PatPatPat
java
kubernetes
spring
spring-cloud-kubernetes

2 Answers

1/25/2021

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.

-- Eugene
Source: StackOverflow

11/14/2021

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.

-- JeyJ
Source: StackOverflow