How to enable kubernetes dashboard via nodeport?

Silk0vsky picture Silk0vsky · Jul 22, 2018 · Viewed 7.1k times · Source

I'm trying to enable dashboard via nodeport service. I have 3 VMs:

  • 192.168.100.31 - master
  • 192.168.100.32 - minion
  • 192.168.100.33 - minion (dashboard here)

After applying:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

Dashboard became accessable via kube-proxy. So I've erited service to become NodePort:

kubectl edit services kubernetes-dashboard -n kube-system

Then I've tried to access the dashboard via https NodePort. And it fails. When I'm trying to visit 192.168.100.31 or 192.168.100.32 like:

https://192.168.100.31:32443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default

Browser hangs out & fired timeout error. Meanwhile the same URL for 192.168.100.33 allow me to add site to the browser exceptions cause of self signed cert and ... fail.

This site can’t be reached
The webpage at https://192.168.100.33:32443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default might be temporarily down or it may have moved permanently to a new web address.
ERR_INVALID_RESPONSE

kubernetes version: v1.11.1

UPD:

kubectl get svc kubernetes-dashboard -n kube-system --export -o yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"creationTimestamp":null,"labels":{"k8s-app":"kubernetes-dashboard"},"name":"kubernetes-dashboard","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/services/kubernetes-dashboard"},"spec":{"ports":[{"nodePort":32443,"port":443,"protocol":"TCP","targetPort":8443}],"selector":{"k8s-app":"kubernetes-dashboard"},"sessionAffinity":"None","type":"NodePort"},"status":{"loadBalancer":{}}}
  creationTimestamp: null
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard
spec:
  externalTrafficPolicy: Cluster
  ports:
  - port: 443
    protocol: TCP
    targetPort: 8443
  selector:
    k8s-app: kubernetes-dashboard
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}

kubectl get svc kubernetes-dashboard -n kube-system

NAME                   TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
kubernetes-dashboard   NodePort   10.96.174.242   <none>        443:32443/TCP   52m

kubectl describe svc kubernetes-dashboard -n kube-system

Name:                     kubernetes-dashboard
Namespace:                kube-system
Labels:                   k8s-app=kubernetes-dashboard
Annotations:              kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"creationTimestamp":null,"labels":{"k8s-app":"kubernetes-dashboard"},"name":"kubernete...
Selector:                 k8s-app=kubernetes-dashboard
Type:                     NodePort
IP:                       10.96.174.242
Port:                     <unset>  443/TCP
TargetPort:               8443/TCP
NodePort:                 <unset>  32443/TCP
Endpoints:                192.0.2.2:8443
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

Answer

VASャ picture VASャ · Jul 31, 2018

Looks like you are using an apiserver type of request while accessing the dashboard service directly via NodePort Service.

Could you check the following links in your browser to access Kubernetes dashboard:

https://192.168.100.31:32433/

https://192.168.100.32:32433/

https://192.168.100.33:32433/