【问题标题】:Kubernetes Kubeadm single node, dashboard "malformed http response"Kubernetes Kubeadm 单节点,仪表板“格式错误的 http 响应”
【发布时间】:2018-03-21 03:39:52
【问题描述】:

我刚刚按照 kubeadm 指南设置了一个单节点 Kubernetes 集群。集群本身看起来不错,所有 pod 都运行正常:

will@kubemaster:~$ sudo kubectl get pods --all-namespaces
NAMESPACE     NAME                                        READY     STATUS    RESTARTS   AGE
kube-system   calico-etcd-w6dkj                           1/1       Running   0          16m
kube-system   calico-node-mjsnr                           2/2       Running   0          16m
kube-system   calico-policy-controller-59fc4f7888-vc6x6   1/1       Running   0          16m
kube-system   etcd-kubemaster                             1/1       Running   0          16m
kube-system   kube-apiserver-kubemaster                   1/1       Running   1          16m
kube-system   kube-controller-manager-kubemaster          1/1       Running   0          16m
kube-system   kube-dns-545bc4bfd4-mbbrl                   3/3       Running   0          16m
kube-system   kube-proxy-wkmlj                            1/1       Running   0          16m
kube-system   kube-scheduler-kubemaster                   1/1       Running   0          16m
kube-system   kubernetes-dashboard-7f9dbb8685-rxwfw       1/1       Running   0          4m

我使用以下方式安装了仪表板:

sudo kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

我尝试通过运行“sudo kubectl proxy”在本地提供 kubrnetes 仪表板。

当我加载“http://127.0.0.1:8001”时,我得到了 API 端点列表,一切看起来都很好。但是当我添加 /ui 来加载仪表板 (http://127.0.0.1:8001/ui) 时,我得到以下响应:

Error: 'malformed HTTP response "\x15\x03\x01\x00\x02\x02"'
Trying to reach: 'http://192.167.141.3:8443/'

另外请注意,上面的 URL 会被重定向到 API:

http://localhost:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/

如果我将 HTTP 替换为 HTTPS,我会收到“安全连接失败,SSL 收到一条超出最大允许长度的记录”。

如果我尝试在不使用 kubectl 代理的情况下加载仪表板,例如使用主 IP,连接被拒绝。

我在Ubuntu 16.04上运行,我的kubectl版本详情如下:

will@kubemaster:~$ sudo kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0", GitCommit:"6e937839ac04a38cac63e6a7a306c5d035fe7b0a", GitTreeState:"clean", BuildDate:"2017-09-28T22:57:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

【问题讨论】:

    标签: kubernetes kubeadm


    【解决方案1】:

    从 v1.7 开始,Dashboard 默认只能通过 HTTPS 访问。

    可通过http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/kubectl proxy 获得。

    使用 HTTP 部署仪表板(不推荐用于生产)

    $ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/alternative/kubernetes-dashboard.yaml
    

    仪表板可以在http://localhost:8001/uikubectl proxy 加载。

    【讨论】:

    • 非常感谢,谷歌搜索后找不到答案,非常感谢!
    • 我在 1.11 中遇到了这个问题,感谢您的快速响应!
    猜你喜欢
    • 2017-09-12
    • 2018-03-06
    • 1970-01-01
    • 2021-06-16
    • 2019-11-23
    • 2021-01-20
    • 1970-01-01
    • 2019-09-10
    • 2020-05-18
    相关资源
    最近更新 更多