无法登录kubernetes仪表板拨号TCP 172.17.0.6:8443:连接:连接被拒绝

时间:2019-09-21 17:58:11

标签: kubernetes

我成功部署了Kubernetes v1.15.2仪表板。检查集群信息:

$ kubectl cluster-info
Kubernetes master is running at http://172.19.104.231:8080
kubernetes-dashboard is running at http://172.19.104.231:8080/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

当我访问仪表板时,结果是:

[root@ops001 ~]# curl -L http://172.19.104.231:8080/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
Error: 'dial tcp 172.17.0.6:8443: connect: connection refused'
Trying to reach: 'https://172.17.0.6:8443/'

这是仪表板状态:

[root@ops001 ~]# kubectl get pods --namespace kube-system
NAME                                   READY   STATUS    RESTARTS   AGE
kubernetes-dashboard-74d7cc788-mk9c7   1/1     Running   0          92m

我该怎么做才能访问仪表板?当我使用代理访问仪表板UI时:

$ kubectl proxy --address='localhost' --port=8086 --accept-hosts='^*$'
Starting to serve on 127.0.0.1:8086

结果是:

[root@ops001 ~]# curl -L http://127.0.0.1:8086/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
Error: 'dial tcp 172.17.0.6:8443: connect: connection refused'
Trying to reach: 'https://172.17.0.6:8443/'

我该怎么做才能解决此问题?

1 个答案:

答案 0 :(得分:1)

我终于发现问题是kubernetes仪表板容器不与代理nginx容器通信。因为代理容器是在kubernetes法兰之前部署的,而不是在同一网络中。尝试将代理nginx容器添加到法兰网络将解决此问题。请检查当前的法兰网络:

[root@ops001 conf.d]# cat /run/flannel/subnet.env
FLANNEL_NETWORK=172.30.0.0/16
FLANNEL_SUBNET=172.30.224.1/21
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true

生成docker的启动参数:

./mk-docker-opts.sh -d /run/docker_opts.env -c

检查参数:

[root@ops001 conf.d] cat /run/docker_opts.env
DOCKER_OPTS=" --bip=172.30.224.1/21 --ip-masq=false --mtu=1450"

向docker服务添加参数:

# vim /lib/systemd/system/docker.service

EnvironmentFile=/run/docker_opts.env
ExecStart=/usr/bin/dockerd $DOCKER_OPTS -H fd://

重新启动docker,容器将加入法兰绒网络,可以彼此通信:

systemctl daemon-reload
systemctl restart docker

希望这对您有帮助!