kubectl 无法连接到服务器:x509:由未知机构签名的证书

2024-02-15

我在一台机器(Windows)上运行 kubectl 时遇到错误

k8s集群运行在CentOs 7 kubernetes cluster 1.7上 师傅、工人

这是我的 .kube\config

  
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://10.10.12.7:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: system:node:localhost.localdomain
  name: system:node:localhost.localdomain@kubernetes
current-context: system:node:localhost.localdomain@kubernetes
kind: Config
preferences: {}
users:
- name: system:node:localhost.localdomain
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
  

集群是使用 kubeadm 构建的,默认证书位于 pki 目录中

kubectl 无法连接到服务器:x509:由未知机构签名的证书


另一个解决方案,以防它对任何人有帮助:

我的场景:

  • 使用 Windows 10
  • 通过 Docker Desktop ui 2.1.0.1 安装的 Kubernetes
  • 安装程序创建的配置文件位于~/.kube/config
  • 中的值~/.kube/config for server is https://kubernetes.docker.internal:6443
  • 使用代理

Issue: kubectl到此端点的命令正在通过代理,我在运行后发现了这一点kubectl --insecure-skip-tls-verify cluster-info dump显示代理 html 错误页面。

Fix:只是确保这个 URL 不通过代理,在我的 bash 中我使用了export no_proxy=$no_proxy,*.docker.internal

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

kubectl 无法连接到服务器:x509:由未知机构签名的证书 的相关文章

随机推荐