---
# System prepended metadata

title: Kubernetes Dashboard UI
tags: [kubernetes]

---

# Kubernetes Dashboard UI

[install](https://artifacthub.io/packages/helm/k8s-dashboard/kubernetes-dashboard?modal=install)

**add repository**

```bash!
# 添加 kubernetes-dashboard 倉庫
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
```

![image](https://hackmd.io/_uploads/B1hOKHAY1g.png)


**Install chart**

```bash!
# 使用 kubernetes-dashboard Chart 部署名為 `kubernetes-dashboard` 的 Helm Release
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard \
  --version 7.10.1 \
  --create-namespace --namespace kubernetes-dashboard
```

![image](https://hackmd.io/_uploads/HJ0FYS0t1x.png)

## 透過 Lens 設置 port-forwarding

**創建用戶**

```yaml!
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
```

**ClusterRoleBinding**

```yaml!
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
```

**建立長久令牌**

```yaml!
apiVersion: v1
kind: Secret
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
  annotations:
    kubernetes.io/service-account.name: "admin-user"   
type: kubernetes.io/service-account-token
```

**獲取秘密保存的令牌**

```bash!
kubectl get secret admin-user -n kubernetes-dashboard -o jsonpath="{.data.token}" | base64 -d
```

**登入**

![image](https://hackmd.io/_uploads/SyRBAq1q1g.png)

**貼上令牌按下登入**

![image](https://hackmd.io/_uploads/BkGc09k91g.png)

**確認 pod**

![image](https://hackmd.io/_uploads/Sk970qJ5yg.png)
