如何解决kubectl exec错误拨号后端:x509:证书由未知授权机构签名
经过长时间的努力,我刚刚创建了集群,并部署了一个示例容器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/busybox 200 OK )
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",BuildDate:"2020-10-14T12:41:49Z",Platform:"linux/amd64"}
解决方法
**劫持我自己的评论以表明虽然下面的内容确实有帮助,但实际上并没有解决我的问题,我在这里发现了一个更好的解决方案(保留下面的位置)。我的集群运营商 kube-apiserver 降级,导致我的证书失败。解决这种降级是解决首要问题所必需的,这会导致 x509 错误。
https://access.redhat.com/solutions/4849711
我的 OCP4 集群也有类似的问题。原来的问题是,节点在启动时提供了自己的自签名证书,但没有添加到受信任的连接中,从而使我的查询失败。
通过使用 openssl 工具(下面的示例)提取证书,然后将生成的 pem 文件添加到 /etc/ssl/certs(允许它识别服务器并解决故障)来解决。
当然,解决此问题的正确方法是分配适当的证书,但这应该可以让您开始使用。发帖以防将来对其他人有帮助。
确定发生故障的节点的内部 IP:
$ oc describe node master01 #(kubectl describe node master01)
master01
$ 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
...输出省略... 内部IP:192.168.50.10
从故障节点上的自签名证书中提取证书信息:
$ cp nodename.pem /etc/ssl/certs
将生成的 pem 文件复制到您的本地证书文件中。
export PUBSUB_EMULATOR_HOST=localhost:8085
再次尝试您的请求。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。