首页 文章

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

提问于
浏览
7

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

k8s集群正在CentOs 7 kubernetes集群1.7 master,worker上运行

这是我的.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:由未知权限签名的证书

5 回答

  • 0

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

    所以在主节点上我们正在运行kubectl代理

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

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

    我现在能够做到

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

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

  • 2

    如果出现错误,您应该导出包含证书的所有kubecfg . kops export kubecfg "your cluster-nameexport KOPS_STATE_STORE=s3://"paste your S3 store" .

    现在,您应该能够访问并查看群集的资源 .

  • 0

    在GCP上

    检查:gcloud版本

    • localMacOS #gcloud版本

    运行:--- localMacOS #gcloud容器集群get-credentials'clusterName'\ --zone = us-'zoneName'

    从控制台获取clusterName和zoneName - 这里:https://console.cloud.google.com/kubernetes/list

    参考:.x509 @market在GCP #Kubernetes上进行部署

  • 0

    跑:

    gcloud container clusters get-credentials standard-cluster-1 --zone us-central1-a --project devops1-218400
    

    这里 devops1-218400 是我的项目名称 . 将其替换为您的项目名称 .

  • 0

    我作为root用户运行 $ kubectl get nodes 时遇到了同样的错误 . 我通过将 kubelet.conf 导出到环境变量来修复它 .

    $ export KUBECONFIG=/etc/kubernetes/kubelet.conf
    $ kubectl get nodes
    

相关问题