【问题标题】:kubectl commands giving errorkubectl 命令给出错误
【发布时间】:2018-11-08 03:28:25
【问题描述】:

我所有的kubectl get 命令都失败,并出现以下错误The connection to the server localhost:8080 was refused - did you specify the right host or port?

我检查了我的/etc/kubernetes/admin.conf 的 ip,除了其他东西之外,它还有以下内容:server: https://10.23.23.19:6443

由于那是我机器的IP,所以我想到了运行这样的命令kubectl get pods --server=10.23.23.19:6443

上面给了我错误-Unable to connect to the server: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03\x01\x00\x02\x02"

我做错了什么?我有一个 3 节点集群,所有这些都在主节点上。当其他 2 个节点加入时,他们确实加入成功,这就是我在屏幕上看到的状态。

我使用本教程(我自己的入门略有偏差)-https://www.linuxtechi.com/install-kubernetes-1-7-centos7-rhel7/

【问题讨论】:

    标签: kubernetes kubectl


    【解决方案1】:

    /etc/kubernetes/admin.conf 是配置系统放置您的配置的位置,但它不是 kubectl 默认使用的位置。 kubectl 查看配置的常用位置是 ~/.kube/config,因此要么将您的配置文件放在那里,要么使用 --kubeconfig <path> 参数提示 kubectl 它需要在不同的位置查看。

    【讨论】:

    • export KUBECONFIG=/etc/kubernetes/admin.conf
    【解决方案2】:

    无法连接到服务器:net/http:HTTP/1.x 传输连接断开:HTTP 响应格式错误“\x15\x03\x01\x00\x02\x02”

    该错误是因为 --server arg 缺少 https://。应该是这样的:

    kubectl get pods --server=https://10.23.23.19:6443

    在添加 https:// 之后,您可能会收到 403 错误,因为仍然没有定义身份验证,但这就是格式错误的 http 响应的原因。

    【讨论】:

      【解决方案3】:

      如果你没有问题:

      curl https://127.0.0.1:10252/healthz -k

      返回是OK

      【讨论】:

        猜你喜欢
        • 2019-08-31
        • 2016-11-11
        • 2019-01-03
        • 2019-09-08
        • 2016-04-15
        • 1970-01-01
        • 2021-07-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多