简体   繁体   English

将 spring-cloud-starter-kubernetes-config 添加为依赖项时引发 Kubernetes 客户端(证书)异常

[英]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:spring-cloud-starter-kubernetes-config依赖添加到我的 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:为了禁用 k8s,我在 bootstrap.yml 中添加了以下参数:

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?我应该添加什么参数,以便如果我在 pom.xml 中有这个依赖项,我在运行测试时禁用 Kubernetes?

That problem could happen due to the installed kubectl .由于安装了kubectl ,可能会发生该问题。 The easiest way to avoid this problem - rename ~/.kube (directory with configs) to some other name like ~/.kube-hide避免此问题的最简单方法 - 将~/.kube (带有配置的目录)重命名为其他名称,例如~/.kube-hide

mv ~/.kube ~/.kube-hide

And when you will need to use your kubectl rename it back当您需要使用您的kubectl时,将其重命名

As stated on the Spring Cloud Kubernetes documentation如 Spring Cloud Kubernetes 文档中所述

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}还要注意这些属性:spring.cloud.kubernetes.config.enabled 和 spring.cloud.kubernetes.secrets.enabled 只有在 bootstrap 中设置时才会生效。{properties|yml}

https://docs.spring.io/spring-cloud-kubernetes/docs/current/reference/html/#kubernetes-ecosystem-awareness 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} .所以,要真正禁用这个属性,它必须在bootstrap.{properties|yml}而不是application.{properties|yml}中设置。

Also, you can pass the value as a VM option:此外,您可以将该值作为 VM 选项传递:

-Dspring.cloud.kubernetes.enabled=false

if you want to run the application locally.如果您想在本地运行应用程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring Boot无法运行依赖于spring-cloud-starter-config的schema.sql - Spring Boot fails to run schema.sql with dependency on spring-cloud-starter-config Kubernetes Java 客户端 API 异常 - Kubernetes Java Client API Exception 在本地禁用 Spring Cloud Kube.netes - Disable Spring Cloud Kubernetes in local 使用 spring-cloud-starter-netflix-eureka-client 依赖项在 pom.xml 中出现错误 - Getting error in pom.xml with spring-cloud-starter-netflix-eureka-client dependency 在 kubernetes 平台上的 spring-cloud-dataflow 中创建调度程序时出现 NullPointerException - NullPointerException when creating scheduler in spring-cloud-dataflow on kubernetes platform Spring Cloud Kube.netes 应用程序未检测到它何时在 pod 中运行 - Spring Cloud Kubernetes application does not detect when it is running in a pod 当 Spring Security 在 Spring Cloud Config Server 上处于活动状态时,Spring Cloud Config Client 不获取配置 - Spring Cloud Config Client not fetching config when Spring Security is active on Spring Cloud Config Server Spring Cloud Kubernetes 重载时序问题 - Spring cloud Kubernetes reload timing issue Spring - 无法导入 spring-cloud-config-client 依赖项。 IntellliJ 错误 - Spring - Cannot import spring-cloud-config-client dependency. IntellliJ Bug 使用来自 Kubernetes Docker 的客户端证书调用端点时出现 SunCertPathBuilderException - SunCertPathBuilderException when calling endpoint using client-side certificate from Kubernetes Docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM