How to access dashboard service internal use Kubernetes

1/18/2018

I have kubernetes-dashboard service with type is ClusterIP. How can I access dashboard internal? I use Alibaba Cloud.

My service.yml

---
kind: Service
apiVersion: v1
metadata:
  labels:
    kubernetes.io/cluster-service: "true"
    app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: ClusterIP
  ports:
  - port: 80
    targetPort: 9090
  selector:
    app: kubernetes-dashboard

I would like to run my dashboard at http://MASTER_IP:80

The status when running kubectl cluster-info:

Kubernetes master is running at https://MASTER_IP:6443
Heapster is running at https://MASTER_IP:6443/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at https://MASTER_IP:6443/api/v1/namespaces/kube-system/services/kube-dns/proxy
kubernetes-dashboard is running at https://MASTER_IP:6443/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy
monitoring-influxdb is running at https://MASTER_IP:6443/api/v1/namespaces/kube-system/services/monitoring-influxdb/proxy

When I access https://MASTER_IP:6443, I got the error default backend - 404.

Note: Don't use NodePort and kubectl proxy.

Many thanks.

-- WorkWe
alibaba-cloud
alibaba-cloud-ecs
kubernetes

2 Answers

1/18/2018

Change the dashboard service type to NodePort then you can access dashboard with any cluster :

  1. change service type from ClusterIP to NodePort kubectl -n kube-system edit svc kubernetes-dashboard

  2. Get the service port number.

    kubectl -n kube-system get svc kubernetes-dashboard -o yaml |grep nodePort

  3. Access dahboard with https://masererverIP:nodeportnumber

-- sfgroups
Source: StackOverflow

1/18/2018

In this answer you can find the different ways to access the dashboard.

If you are not using NodePort or kubectl proxy, your best options are

API Server

In case Kubernetes API server is exposed and accessible from outside you can directly access dashboard at: https://<master-ip>:<apiserver-port>/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

Ingress

Dashboard can be also exposed using Ingress resource. For example

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: kubernetes-dashboard-ingress
 namespace: kube-system
spec:
 rules:
host: kubernetes
     http:
       paths:
path: /ui
           backend:
             serviceName: kubernetes-dashboard
             servicePort: 80
-- Jose Armesto
Source: StackOverflow