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?