【问题标题】:kubectl exec error dialing backend: x509: certificate signed by unknown authoritykubectl exec 错误拨号后端:x509:证书由未知机构签名
【发布时间】:2021-02-01 03:47:21
【问题描述】:

经过长时间的努力,我刚刚创建了集群,部署了一个示例容器busybox,现在我尝试运行命令 exec,但出现以下错误:

错误拨号后端:x509:证书由未知机构签名

我该如何解决这个问题:这是 v=9 日志级别的命令输出。 kubectl exec -v=9 -ti busybox -- nslookup kubernetes 我还在日志中注意到,这个失败的 curl 命令实际上是第一个 GET 命令传递的第二个命令,它返回结果没有任何问题.. (GET https://myloadbalancer.local:6443/api/v1/namespaces/default/pods/busybox200 OK em>)

curl -k -v -XPOST  -H "X-Stream-Protocol-Version: v4.channel.k8s.io" -H "X-Stream-Protocol-Version: v3.channel.k8s.io" -H "X-Stream-Protocol-Version: v2.channel.k8s.io" -H "X-Stream-Protocol-Version: channel.k8s.io" -H "User-Agent: kubectl/v1.19.0 (linux/amd64) kubernetes/e199641" 'https://myloadbalancer.local:6443/api/v1/namespaces/default/pods/busybox/exec?command=nslookup&command=kubernetes&container=busybox&stdin=true&stdout=true&tty=true'
I1018 02:19:40.776134  129813 round_trippers.go:443] POST https://myloadbalancer.local:6443/api/v1/namespaces/default/pods/busybox/exec?command=nslookup&command=kubernetes&container=busybox&stdin=true&stdout=true&tty=true 500 Internal Server Error in 43 milliseconds
I1018 02:19:40.776189  129813 round_trippers.go:449] Response Headers:
I1018 02:19:40.776206  129813 round_trippers.go:452]     Content-Type: application/json
I1018 02:19:40.776234  129813 round_trippers.go:452]     Date: Sun, 18 Oct 2020 02:19:40 GMT
I1018 02:19:40.776264  129813 round_trippers.go:452]     Content-Length: 161
I1018 02:19:40.776277  129813 round_trippers.go:452]     Cache-Control: no-cache, private
I1018 02:19:40.777904  129813 helpers.go:216] server response object: [{
  "metadata": {},
  "status": "Failure",
  "message": "error dialing backend: x509: certificate signed by unknown authority",
  "code": 500
}]
F1018 02:19:40.778081  129813 helpers.go:115] Error from server: error dialing backend: x509: certificate signed by unknown authority
goroutine 1 [running]:

添加更多信息: 这是在 UBUNTU 20.04 上。作为初学者,我逐步手动创建集群,我需要这种经验,而不是使用 kubeadm 或 minikube 之类的工具

xxxx@master01:~$ kubectl exec -ti busybox -- nslookup kubernetes
Error from server: error dialing backend: x509: certificate signed by unknown authority
xxxx@master01:~$ kubectl get pods --all-namespaces
NAMESPACE              NAME                                         READY   STATUS    RESTARTS   AGE
default                busybox                                      1/1     Running   52         2d5h
kube-system            coredns-78cb77577b-lbp87                     1/1     Running   0          2d5h
kube-system            coredns-78cb77577b-n7rvg                     1/1     Running   0          2d5h
kube-system            weave-net-d9jb6                              2/2     Running   7          2d5h
kube-system            weave-net-nsqss                              2/2     Running   0          2d14h
kube-system            weave-net-wnbq7                              2/2     Running   7          2d5h
kube-system            weave-net-zfsmn                              2/2     Running   0          2d14h
kubernetes-dashboard   dashboard-metrics-scraper-7b59f7d4df-dhcpn   1/1     Running   0          2d3h
kubernetes-dashboard   kubernetes-dashboard-665f4c5ff-6qnzp         1/1     Running   7          2d3h
tinashe@master01:~$ kubectl logs busybox
Error from server: Get "https://worker01:10250/containerLogs/default/busybox/busybox": x509: certificate signed by unknown authority
xxxx@master01:~$

xxxx@master01:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T12:50:19Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T12:41:49Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}

【问题讨论】:

  • 您好,您可以添加更多关于您的 k8s 集群的详细信息吗?您使用了哪种集群部署方法?什么版本?什么基础架构和主机操作系统?
  • 我还注意到该错误听起来与我遇到的另一个问题非常相似 stackoverflow.com/questions/64423638/…
  • kubectl get pods --all-namespaces -o wide。您的一些 pod 正在不断地重新启动。这不能与特定节点上的某些证书​​问题有关吗?

标签: kubernetes kubectl kubelet


【解决方案1】:

**劫持我自己的评论以表明虽然下面的内容确实帮助了一分钟,但实际上并没有解决我的问题,我在这里发现了一个更好的解决方案(保留在下面)。我的集群操作员 kube-apiserver 已降级,导致我的证书失败。解决降级是解决总体问题所必需的,这会导致 x509 错误。

https://access.redhat.com/solutions/4849711


我的 OCP4 集群也有类似的问题。原来问题是节点在启动时提供了自己的自签名证书,并且错过了添加到受信任的连接,导致我的查询失败。

通过使用 openssl 工具提取证书(如下示例)解决,然后将生成的 pem 文件添加到 /etc/ssl/certs(允许它识别服务器并解决故障)。

当然,解决此问题的正确方法是分配适当的证书,但这应该可以让您开始使用您已经开始使用的东西。发帖以防将来对其他人有所帮助。

确定发生故障的节点的内部 IP:

$ oc get nodes #(kubectl get nodes)  

master01

$ oc describe node master01 #(kubectl describe node master01)    

...输出省略... 内部IP:192.168.50.10

从故障节点上的自签名证书中拉取证书信息:

$ echo | openssl s_client -showcert
s -servername 192.168.50.10 -connect 192.168.50.10:443 2>/
dev/null | openssl x509 -inform pem -noout -text > nodename.pem    

将生成的 pem 文件复制到本地证书文件。

$ cp nodename.pem /etc/ssl/certs    

再次尝试您的请求。

【讨论】:

    猜你喜欢
    • 2019-03-07
    • 1970-01-01
    • 2021-01-29
    • 2020-03-16
    • 2018-02-24
    • 2023-01-09
    • 2017-12-23
    • 1970-01-01
    • 2016-03-20
    相关资源
    最近更新 更多