Unable to access the EC2 Kubernetes dashboard

4/24/2020

I followed How can I access to kubernetes dashboard using NodePort in a remote cluster for testing?

My Kubernetes cluster runs in Amazon EC2 instances and cluster services looks like below

$ kubectl get services --all-namespaces
NAMESPACE     NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
default       kubernetes             ClusterIP   100.64.0.1      <none>        443/TCP         5h54m
kube-system   kube-dns               ClusterIP   100.64.0.10     <none>        53/UDP,53/TCP   5h53m
kube-system   kubernetes-dashboard   NodePort    100.68.178.51   <none>        443:31872/TCP   5h47m

$ kubectl cluster-info
Kubernetes master is running at https://api.selumalai.k8s.com
KubeDNS is running at https://api.selumalai.k8s.com/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

I have exposed the NodePort at 31872. If I access the dashboard in browser using

$ kubectl  proxy -p 8001 &
$ curl https://api.selumalai.k8s.com:31872

Its loading forever. What am I doing wrong ?

-- saranya elumalai
amazon-ec2
kubernetes
kubernetes-dashboard

1 Answer

4/27/2020

You need to add a security group to your instance to allow traffic for port 31872.

It's explained how to do so here.

If you use kubectl proxy it can be accessed localy only, which is stated in the docs:

...

kubectl proxy

... The UI can only be accessed from the machine where the command is executed. See kubectl proxy --help for more options.

Also here is a guide from AWS on how to Deploy the Kubernetes Dashboard (web UI). You can try running a L7 ELB to expose the Dashboard which is explained here.

-- Crou
Source: StackOverflow