kubectl 无法连接到服务器:x509:由未知权威签名的证书 [英] kubectl unable to connect to server: x509: certificate signed by unknown authority

查看:82
本文介绍了kubectl 无法连接到服务器:x509:由未知权威签名的证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一台机器(windows)上运行 kubectl 时出错

k8s 集群运行在 CentOs 7 kubernetes 集群 1.7主人,工人

这是我的 .kubeconfig

<前><代码>api版本:v1集群:- 簇:证书颁发机构数据:已编辑服务器:https://10.10.12.7:6443名称:kubernetes上下文:- 语境:集群:kubernetes用户:系统:节点:localhost.localdomain名称:system:node:localhost.localdomain@kubernetes当前上下文:系统:节点:localhost.localdomain@kubernetes种类:配置喜好: {}用户:- 名称:系统:节点:localhost.localdomain用户:客户端证书数据:已编辑客户端密钥数据:已编辑

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

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

解决方案

我只是想分享,抱歉我没能早点提供这个,因为我刚刚意识到这是造成的

所以在主节点上我们运行了一个 kubectl 代理

kubectl proxy --address 0.0.0.0 --accept-hosts '.*'

我停止了这个,瞧,错误消失了.

我现在可以做

<前>kubectl 获取节点姓名 状态 年龄 版本centos-k8s2 Ready 3d v1.7.5localhost.localdomain Ready 3d v1.7.5

我希望这能帮助那些偶然发现这种情况的人

i'm getting an error when running kubectl one one machine (windows)

the k8s cluster is running on CentOs 7 kubernetes cluster 1.7 master, worker

Here's my .kubeconfig

  
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
  

the cluster is built using kubeadm with the default certificates on the pki directory

kubectl unable to connect to server: x509: certificate signed by unknown authority

解决方案

I just want to share, sorry I wasn't able to provide this earlier as I just realized this is causing

so on the master node we're running a kubectl proxy

kubectl proxy --address 0.0.0.0 --accept-hosts '.*'

I stopped this and voila the error was gone.

I'm now able to do

    kubectl get nodes
NAME                    STATUS    AGE       VERSION
centos-k8s2             Ready     3d        v1.7.5
localhost.localdomain   Ready     3d        v1.7.5

I hope this helps those who stumbled upon this scenario

这篇关于kubectl 无法连接到服务器:x509:由未知权威签名的证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆