> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Dashboard

> You can visualize and manage cluster resources by deploying Kubernetes Dashboard. You can provide secure access with RBAC configuration and make it accessible externally via NodePort.

## Deploying Dashboard Interface

The Dashboard user interface is not deployed by default. Follow the steps below to deploy:

<Info>
  To protect your cluster data, Dashboard is deployed with at least one RBAC configuration by default. Dashboard only supports login with Bearer Token.
</Info>

```bash theme={null}
vi dashboard-service.yaml
```

```yaml theme={null}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
```

```bash theme={null}
vi dashboard-adminuser.yaml
```

```yaml theme={null}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: admin-user
    namespace: kubernetes-dashboard
```

```bash theme={null}
kubectl apply -f dashboard-service.yaml
kubectl apply -f dashboard-adminuser.yaml
kubectl create clusterrolebinding permissive-binding --clusterrole=cluster-admin --user=admin --user=kubelet --group=system:serviceaccounts
kubectl create clusterrolebinding kubernetes-dashboard -n kube-system --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
```

```bash theme={null}
vi dashboard-deployment.yaml
```

```yaml theme={null}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
```

```bash theme={null}
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.1.0/aio/deploy/recommended.yaml
```

## NodePort Setting

When Kubernetes dashboard is installed with the steps above, it will open with ClusterIP by default. To access externally, we need to change the value in the Service as follows.

```bash theme={null}
kubectl -n kubernetes-dashboard edit service kubernetes-dashboard
```

```yaml theme={null}
apiVersion: v1
...
name: kubernetes-dashboard
namespace: kube-system
resourceVersion: "343478"
selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard-head
uid: 8e48f478-993d-11e7-87e0-901b0e532516
spec:
  clusterIP: <YOUR_CLUSTER_IP>
  externalTrafficPolicy: Cluster
  ports:
    - port: 443
      protocol: TCP
      targetPort: 8443
      nodePort: 32100
  selector:
    k8s-app: kubernetes-dashboard
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}
```

Then we need to check the port where Dashboard is located. There should be a service view similar to the following.

```bash theme={null}
kubectl -n kubernetes-dashboard get service kubernetes-dashboard
```

Example output:

```
NAME                   TYPE       CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE
kubernetes-dashboard   NodePort   <YOUR_CLUSTER_IP>   <none>        443:32100/TCP   13d
```

Dashboard is displayed on port 32100 (HTTPS). You can now access it from your browser: `https://<YOUR_CLUSTER_IP>:32100`.

**Getting Token:**

```bash theme={null}
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | awk '/^deployment-controller-token-/{print $1}') | awk '$1=="token:"{print $2}'
```
