How To Install Kubernetes Dashboard with NodePort

Posted on 255 views

Kubernetes dashboard is a web-based user interface which provides information on the state of the Kubernetes cluster resources and any errors that may occur. The dashboard can be used to deploy containerized applications to the cluster, troubleshoot deployed applications, as well as the general management of the cluster resources.

The deployment of Deployments, StatefulSets, DaemonSets, Jobs, Services and Ingress can be done from the dashboard or from the terminal with kubectl. if you want to scale a Deployment, initiate a rolling update, restart a pod, create a persistent volume and persistent volume claim, you can do all from the Kubernetes dashboard.

Also checkout the article on Authenticate Kubernetes Dashboard Users With Active Directory

Step 1: Configure kubectl

We’ll use the kubectl kubernetes management tool to deploy dashboard to the Kubernetes cluster. You can configure kubectl using our guide below.

The guide in the link demonstrates how you can configure and access multiple clusters with same kubectl configuration file.

Step 2: Deploy Kubernetes Dashboard

The default Dashboard deployment contains a minimal set of RBAC privileges needed to run. You can deploy Kubernetes dashboard with the command below.

kubectl apply -f

You can as well download and apply the file locally:

kubectl apply -f recommended.yaml

Set Service to use NodePort

This will use the default values for the deployment. The services are available on ClusterIPs only as can be seen from the output below:

$ kubectl get svc -n kubernetes-dashboard
NAME                        TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
dashboard-metrics-scraper   ClusterIP           8000/TCP   23s
kubernetes-dashboard        ClusterIP            443/TCP    25s

Patch the service to have it listen on NodePort:

kubectl --namespace kubernetes-dashboard patch svc kubernetes-dashboard -p '"spec": "type": "NodePort"'

Confirm the new setting:

$ kubectl get svc -n kubernetes-dashboard kubernetes-dashboard -o yaml
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  - IPv4
  ipFamilyPolicy: SingleStack
  - nodePort: 30506
    port: 443
    protocol: TCP
    targetPort: 8443
    k8s-app: kubernetes-dashboard
  sessionAffinity: None
  type: NodePort
  • NodePort exposes the Service on each Node’s IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created.
$ vim nodeport_dashboard_patch.yaml
  - nodePort: 32000
    port: 443
    protocol: TCP
    targetPort: 8443

Apply the patch

kubectl -n kubernetes-dashboard patch svc kubernetes-dashboard --patch "$(cat nodeport_dashboard_patch.yaml)"

Check deployment status:

$ kubectl get deployments -n kubernetes-dashboard                              
NAME                        READY   UP-TO-DATE   AVAILABLE   AGE
dashboard-metrics-scraper   1/1     1            1           86s
kubernetes-dashboard        1/1     1            1           86s

Two pods should be created – One for dashboard and another for metrics.

$ kubectl get pods -n kubernetes-dashboard
NAME                                         READY   STATUS    RESTARTS   AGE
dashboard-metrics-scraper-7b64584c5c-xvtqp   1/1     Running   0          2m4s
kubernetes-dashboard-566f567dc7-w59rn        1/1     Running   0          2m4s

Since I changed service type to NodePort, let’s confirm if the service was actually created.

$ kubectl get service -n kubernetes-dashboard  
NAME                        TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
dashboard-metrics-scraper   ClusterIP           8000/TCP        8m40s
kubernetes-dashboard        NodePort           443:32000/TCP   8m40s

Step 3: Accessing Kubernetes Dashboard

My Service deployment was assigned a port 32000/TCP.

# Example

Let’s confirm if access to the dashboard is working.


You need a token to access the dashboard, check our guides:

You should see a web dashboard which looks similar to below.


Nginx Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
  name: k8s-dashboard
  namespace: kubernetes-dashboard
  annotations: "true" "true"
    - hosts:
      secretName: tls-secret
    - host:
        - path: /
            serviceName: kubernetes-dashboard
            servicePort: 443



Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.