2

一段时间以来,我一直在使用 Kubernetes .net 客户端库版本来从容器内访问 Kubernetes api。今天我从客户端库版本 1.6.11 更新到 4.0.21 但这破坏了客户端身份验证的某些部分。

这是我得到的例外:

HttpRequestException. The SSL connection could not be established, see inner exception.
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
   (rest of the stack trace ommited)

除了内部例外:

AuthenticationException. The remote certificate is invalid because of errors in the certificate chain: PartialChain.
   at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
   at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)

我使用默认的 inClusterConfiguration 来创建 Kubernetes 客户端的实例:

KubernetesClientConfiguration config = KubernetesClientConfiguration.InClusterConfig();
Kubernetes client = new Kubernetes(config);

在验证我仍然可以通过 curl 使用与存储在/var/run/secrets/kubernetes.io/serviceaccount/.

我对 SSL 不是很熟悉,但经过一番挣扎后,我找到了一种解决方法,方法是将 ca.cert 文件从 serviceaccount 目录复制到/usr/local/share/ca-certificates/并运行update-ca-certificates,但我确实想知道现在需要执行此操作的发生了什么变化。

有什么方法可以配置客户端,使其自动完成或以其他方式解决?

4

1 回答 1

0

从客户的 Github 中,我发现这个问题表明比我发现的更好的解决方法。

KubernetesClientConfiguration config = KubernetesClientConfiguration.InClusterConfig();
config.TcpKeepAlive = false; 

Kubernetes client = new Kubernetes(config);
于 2021-03-29T07:15:08.013 回答