简体   繁体   中英

Kubernetes client (certificate) exception is thrown when spring-cloud-starter-kubernetes-config added as a dependency

I encountered the following error when added spring-cloud-starter-kubernetes-config dependency to my pom.xml:

io.fabric8.kubernetes.client.KubernetesClientException: An error has occurred. Caused by: java.security.cert.CertificateException: Could not parse certificate: java.io.IOException: Empty input Caused by: java.io.IOException: Empty input

To disable k8s, I added in bootstrap.yml following param:

spring:
  cloud:
    kubernetes:
      enabled: false

But even after that nothing changed and the error remained.

Where else should I look? What parameter should I add so that if I have this dependency in pom.xml, I disable Kubernetes when running tests?

That problem could happen due to the installed kubectl . The easiest way to avoid this problem - rename ~/.kube (directory with configs) to some other name like ~/.kube-hide

mv ~/.kube ~/.kube-hide

And when you will need to use your kubectl rename it back

As stated on the Spring Cloud Kubernetes documentation

Also note that these properties: spring.cloud.kubernetes.config.enabled and spring.cloud.kubernetes.secrets.enabled only take effect when set in bootstrap.{properties|yml}

https://docs.spring.io/spring-cloud-kubernetes/docs/current/reference/html/#kubernetes-ecosystem-awareness

So, to actually disable this property, it has to be set in bootstrap.{properties|yml} and not in application.{properties|yml} .

Also, you can pass the value as a VM option:

-Dspring.cloud.kubernetes.enabled=false

if you want to run the application locally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM