spring-cloud-kubernetes: Context load test fails with Spring Boot 2.6.1 and Spring Cloud 2021.0.0

Describe the bug While running the contextLoads test Spring Cloud Kubernetes fails with the following:

Error creating bean with name 'kubernetesKubectlCreateProcessor': Unsatisfied dependency expressed through field 
'apiClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with
 name 'defaultApiClient' defined in class path resource 
[io/kubernetes/client/spring/extended/controller/config/KubernetesInformerAutoConfiguration.class]: Bean 
instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [io.kubernetes.client.openapi.ApiClient]: Factory method 'defaultApiClient' threw exception;
 nested exception is java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "expiryObj" is null
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'defaultApiClient' defined in class path resource [io/kubernetes/client/spring/extended/controller/config/KubernetesInformerAutoConfiguration.class]:
 Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
 Failed to instantiate [io.kubernetes.client.openapi.ApiClient]: Factory method 'defaultApiClient' threw exception; 
nested exception is java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "expiryObj" is null
...
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.kubernetes.client.openapi.ApiClient]: 
Factory method 'defaultApiClient' threw exception; nested exception is java.lang.NullPointerException: 
Cannot invoke "Object.getClass()" because "expiryObj" is null
...
Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "expiryObj" is null
	at io.kubernetes.client.util.authenticators.GCPAuthenticator.isExpired(GCPAuthenticator.java:54)
	at io.kubernetes.client.util.KubeConfig.getAccessToken(KubeConfig.java:214)

Is there a way to tell Spring Cloud Kubernetes to not try to access the API and authenticate while running JUnit tests?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Yep, this worked! Thanks @ryanjbaxter!

Adding:

kubernetes.informer.enabled=false
kubernetes.manifests.enabled=false

to my bootstrap.properties in java/test/resources worked!