kubectl 给出错误:无法连接到服务器:x509:由未知颁发机构签名的证书

发布于 2025-01-12 13:04:46 字数 620 浏览 3 评论 0原文

Mac 上的 docker 桌面出现错误:

Unable to connect to the server: x509: certificate signed by unknown authority

以下答案没有多大帮助:

我的系统详细信息:

  • 操作系统:macOS Big Sur 版本 11.6

  • Docker 桌面版本:v20.10.12

  • Kubernetes 版本:v1.22.5

当我这样做时:

kubectl get pods

我收到以下错误:

Unable to connect to the server: x509: certificate signed by unknown authority

docker desktop on mac is getting error:

Unable to connect to the server: x509: certificate signed by unknown authority

The following answers didn't helped much:

My system details:

  • Operating system: macOS Big Sur Version 11.6

  • Docker desktop version: v20.10.12

  • Kubernetes version: v1.22.5

When I do:

kubectl get pods

I get the below error:

Unable to connect to the server: x509: certificate signed by unknown authority

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮云落日 2025-01-19 13:04:46

从评论中发布答案


正如在其他问题和答案之后出现的那样,之前安装的 Rancher 集群留下了痕迹:证书和上下文在 ~/.kube/config 中。

在这种情况下,本地开发/测试的解决方案是完全删除包含配置的 ~/.kube 文件夹,并从头开始初始化集群。

Posting the answer from comments


As appeared after additional questions and answers, there was a previous installation of rancher cluster which left its traces: certificate and context in ~/.kube/config.

The solution in this case for local development/testing is to delete entirely ~/.kube folder with configs and init the cluster from the scratch.

不寐倦长更 2025-01-19 13:04:46

如果您使用的是公司笔记本电脑,并且您所做的一切都通过代理,您将收到此消息。因此,当 docker Desktop 尝试连接到 ~/.kube/config 中定义的服务器时,它将尝试通过代理,您将需要公司颁发的证书。长话短说,你被公司阻止了......要解决这个问题,你可以添加 no proxy props,添加任何值服务器:在~/.kube/config中定义的internal.docker 。这意味着,如果我连接到在笔记本电脑本地运行的 docker 集群,请不要通过代理引导我的流量。

在执行 docker info 时,设置无代理后,您应该看到类似这样的内容。

docker info | grep -i proxy

 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal,localhost,127.0.0.1,.local,.us.example.com,.examplecorp.com,.examplevcn.com,kubernetes.docker.internal
  hubproxy.docker.internal:5000

If you are using a corporate laptop, and everything you do goes through a proxy, you will get this message. Hence, when docker desktop tries to connect to the server defined in ~/.kube/config, it will try to go through the proxy and you will need the cert issued by the company. Long story short, you are getting blocked by the the company... To fix, you can add the no proxy props, adding what ever value server: internal.docker defined in~/.kube/config . Meaning, if I am connecting to docker cluster which runs locally in my laptop, do not direct my traffic through proxy.

When doing docker info, after setting no proxy, you should see something like this.

docker info | grep -i proxy

 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal,localhost,127.0.0.1,.local,.us.example.com,.examplecorp.com,.examplevcn.com,kubernetes.docker.internal
  hubproxy.docker.internal:5000
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文