Install Kubernetes Dashboard

Lars J├Ânsson 2022-12-02

Instructions of how to install the Dashboard on a running Kubernetes cluster. It is based on the recommended setup in the Kubernetes Dashboard README file.



Create private key and certificate that can be used when accessing the Dashboard. It is assumed that they are available at $HOME/certs and named dashboard.key resp. dashboard.crt.

More information about how to create the certificate is described here.

YAML definition

For Dashboard to pickup the certificates, you must pass arguments --tls-cert-file=/dashboard.crt and --tls-key-file=/dashboard.key to the container. First download the file.


Under Deployment section, add arguments to pod definition, it should look as follows:

    - --tls-cert-file=/dashboard.crt
    - --tls-key-file=/dashboard.key
    - --auto-generate-certificates

--auto-generate-certificates can be left in place, and will be used as a fallback.


Create the namespace for the Dashboard and install the secret (key and certificate):

kubectl create namespace kubernetes-dashboard
kubectl create secret generic kubernetes-dashboard-certs --from-file=$HOME/certs -n kubernetes-dashboard

Install the Dashboard:

kubectl apply -f recommended.yaml 

The Dashboard is available as a NodePort. This way of accessing Dashboard is only recommended for development environments in a single node setup.

Edit kubernetes-dashboard service:

kubectl -n kubernetes-dashboard edit service kubernetes-dashboard

You should see yaml representation of the service. Change type: ClusterIP to type: NodePort and save file.

  sessionAffinity: None
  type: NodePort

Next we need to check port on which Dashboard was exposed.

kubectl -n kubernetes-dashboard get service kubernetes-dashboard
NAME                   TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
kubernetes-dashboard   NodePort   <none>        443:31262/TCP   4m3s

Dashboard has been exposed on port 31262 (HTTPS). Now you can access it from your browser at: https://<master-ip>:31262. master-ip can be found by executing kubectl cluster-info.

Dashboard user

An admin user is needed when accessing the Dashboard. It is created using the Service Account mechanism of Kubernetes and granting this user admin permissions. A bearer token tied to the user is used for login to the Dashboard.

IMPORTANT: Make sure that you know what you are doing before proceeding. Granting admin privileges to Dashboard's Service Account might be a security risk.

Creating the user

Create a dashboard-adminuser.yaml file with the following content:

# Admin user for the Dashboard

apiVersion: v1
kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard


kind: ClusterRoleBinding
  name: admin-user
  kind: ClusterRole
  name: cluster-admin
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard

Create the admin user:

kubectl apply -f dashboard-adminuser.yaml

Getting the bearer token

Now we need to find the token we can use to log in. Execute the following command:

kubectl -n kubernetes-dashboard create token admin-user

It should print something like:


The token can be copied and pasted into Enter token field on the login screen.