External endpoint of Kubernetes dashboard

5/19/2016

I was just wondering how to manually set the external endpoint used by the Kubernetes web dashboard.

After creating the namespace kube-system, I ran the following:

kubectl create -f https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml

Is there a flag I can use to specify which tcp port to use for external access? As far as I can tell it's just randomly assigning one. I've looked through the documentation but I'm having a hard time finding a solution. Any help would be appreciated.

-- Sean Nelson
dashboard
docker
endpoint
kubernetes

1 Answer

5/19/2016

You can specify the desired port as the nodePort in the yaml spec that you use to create the service. In this case, where the yaml file you linked to defines the service as:

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

You would want to define it as below, assuming your desired port number is 33333:

- kind: Service
  apiVersion: v1
  metadata:
    labels:
      app: kubernetes-dashboard
      kubernetes.io/cluster-service: "true"
    name: kubernetes-dashboard
    namespace: kube-system
  spec:
    type: NodePort
    ports:
    - port: 80
      targetPort: 9090
      nodePort: 33333
    selector:
      app: kubernetes-dashboard
-- Alex Robinson
Source: StackOverflow