0

I have a spring boot (2.7.0) with spring-cloud-depependencies (2021.0.3) under GKE, where since I noticed Kubernetes api client is failing to connect but just few milliseconds later succeeding (And I can't figure out the reason why yet, although one detail is GKE cluster was upgraded, but that is another story), I rather on the meantime to fail fast the spring boot application and try to wait till the configmap is ready to be read.

In order to do so, I configured my bootstrap as follows:

  profiles: some-profile
  cloud:
    kubernetes:
      config:
        retry:
          initial-interval: 1000
          max-attempts: 6
          max-interval: 2000
          multiplier: 1.1
        fail-fast: true
        enabled: true
        enableApi: true
        namespace: some-namespace
        name: someConfigmapName
      reload:
        enabled: true
        monitoring-config-maps: true
        mode: event
        strategy: refresh 

I added the respective dependencies as well:

    <dependency>
        <groupId>org.springframework.retry</groupId>
        <artifactId>spring-retry</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>

As those are the steps declared here: https://docs.spring.io/spring-cloud-kubernetes/docs/current/reference/html/#configmap-propertysource

You can also make your application retry loading ConfigMap property sources on a failure. First, you need to set spring.cloud.kubernetes.config.fail-fast=true. Then you need to add spring-retry and spring-boot-starter-aop to your classpath. You can configure retry properties such as the maximum number of attempts, backoff options like initial interval, multiplier, max interval by setting the spring.cloud.kubernetes.config.retry.* properties.

But I'm getting as an error:

APPLICATION FAILED TO START
***************************

Description:

A component required a bean named 'configServerRetryInterceptor' that could not be found.


Action:

Consider defining a bean named 'configServerRetryInterceptor' in your configuration.

Why should I add the configServerRetryInterceptor bean? shouldn't that one instantiated automatically based on the steps declared in the the documentation? Regardless if that, if I create such a @bean in a class annotated with @Configuration it doesn't work either.

What step am I missing?

Columb1a
  • 463
  • 2
  • 11
  • 25
  • can you try our latest `3.x.x` dependencies in spring-cloud-kubernetes please? – Eugene Feb 18 '23 at 06:05
  • Did you mean to start using Spring Boot 3.x.x dependencies? That won't be possible as that deserves first a proper migration of dependencies. Also, if that is what you meant, why to do so? I don't see any reason as that is not part of the instructions in the documentation to try to reload the configmap. – Columb1a Mar 07 '23 at 14:27
  • I only recently (1.5 years) been working in the `3.x.x` branches (as a spring-cloud-kubernetes contributor) that is why I was suggesting to try that. But if that is not an option, you can go to the github repo and open a defect. But without a minimal, reproducible example that we can see this in action, the chances of helping you are rather slim. – Eugene Mar 07 '23 at 14:36

0 Answers0