spring-cloud-kubernetes: Upgrading to Spring Boot 3, config does not load - Cannot enhance @Configuration KubernetesClientAutoConfiguration

Describe the bug I’m upgrading an existing project to spring boot 3 and using the spring-cloud-kubernetes-3.0.0-RC3 dependency.

When I start the application it is no longer loading the configuration and I get the following error message:

Cannot enhance @Configuration bean definition 'org.springframework.cloud.kubernetes.client.KubernetesClientAutoConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.

Sample The is the configuration I am using:

spring:
  cloud:
    kubernetes:
      enabled: true
      discovery:
        enabled: true
        all-namespaces: true # Servlet container configuration
      reload:
        period: 1000
        enabled: true
        mode: event
      config:
        enabled: true
        name: test-service
        sources:
          - name: test-service

Not sure what other code would be useful to supply, I really don’t know where to start with this. Spent the past few days googling, and I’m sure I’m missing something obvious.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 22 (9 by maintainers)

Most upvoted comments

Thank you so much for taking the time to look into this. I will implement this today and let you know how I get on.

OK, will work on it and let you know.

Also, an interesting note, I am able to configure the application using json stored in a ConfigMap and passing the following environment value:

  env:
    - name: SPRING_PROFILES_ACTIVE
      value: dev,kubernetes
    - name: SPRING_APPLICATION_JSON
      valueFrom:
        configMapKeyRef:
          name: spring-config
          key: application.json

Obviously this doesn’t use spring cloud kubernetes, but thought it worthy of note.

Thanks, I will try to see if I can create a project that replicates the issue. Unfortunately I cannot share the current source code, but can probably create a stripped down version.