Can not login to kubernetes dashboard dial tcp 172.17.0.6:8443: connect: connection refused

9/21/2019

I deployed Kubernetes v1.15.2 dashboard successfully. Checking the cluster info:

$ 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'.

When I access the dashboard, the result is:

[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/'

This is dashboard status:

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

What should I do to access the dashboard? When I using proxy to access dashboard UI:

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

the result is:

[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/'

What should I do to fix this problem?

-- Dolphin
kubernetes

1 Answer

9/23/2019

I finally find the problem is kubernetes dashboard pod container does not communicate with the proxy nginx container. Because the proxy container is deployed before kubernetes flannel,and not in the same network.Trying to add proxy nginx container to flannel network would solve the problem.Check current flannel network:

[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

generate start parameter of docker:

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

check the parameter:

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

add paramter to docker service:

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

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

restart docker and the container would join the flannel network,could communicate with each other:

systemctl daemon-reload
systemctl restart docker

hope this may help you!

-- Dolphin
Source: StackOverflow