【问题标题】:Kubernetes client library AuthenticationExceptionKubernetes 客户端库 AuthenticationException
【发布时间】:2021-06-23 09:24:02
【问题描述】:

我一直在使用 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 Client 的实例:

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

在验证我仍然可以使用与存储在/var/run/secrets/kubernetes.io/serviceaccount/ 中的 pod 服务帐户关联的令牌通过 curl 与 API 通信之后。

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

我可以通过某种方式配置客户端,使其自动完成或以其他方式解决吗?

【问题讨论】:

    标签: asp.net-core authentication ssl kubernetes kubernetes-security


    【解决方案1】:

    我从客户的 Github 中找到了 this issue,这表明比我找到的解决方法更好。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-30
      • 1970-01-01
      • 1970-01-01
      • 2021-07-14
      相关资源
      最近更新 更多