ref:

https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/

 

1. deploy ui

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml

如果无法访问这个文件:

可以下载这里的这个yaml: 链接: https://pan.baidu.com/s/1xFkUqTwmxtjBVkbMuHw7jQ 提取码: txmq 复制这段内容后打开百度网盘手机App,操作更方便哦

2. 生成token

dash_user.yaml:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
kubectl apply -f dash_user.yaml 
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')

上面这个命令会显示一个token:

Name:         admin-user-token-c622q
Namespace:    kubernetes-dashboard
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: admin-user
              kubernetes.io/service-account.uid: 1e7d4571-e6d5-42d7-b0e2-f92cfc2267cf

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1025 bytes
namespace:  20 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6ImgzVEdMRVNiQzZHdDlpV3J6REJiWUJncGhPeEZnby1USEN1RDZGQXcwdWcifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLWM2MjJxIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIxZTdkNDU3MS1lNmQ1LTQyZDctYjBlMi1mOTJjZmMyMjY3Y2YiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.eOa51VsiM9_4uU7OBeeriSfqvgGEOW6Pru0cXKketTH66CppLzk5Dp0wIz29pRisQCgzNIYpxPzxQsKu0qA3PcLPfvdqgbSGaUL0TYnSs6eAOOzY8q8krJ4BtTrMXJk1NkkN6KO2nU2aKUHLVH_uJHhmEpwTtJEipFo37bsDPFm9CrBMqNCL9tLKdZNF51sK96hvIsXBofWLo_jRbVM61XqPjPUqgNDhQrSqBqIbYsc6UvyzVMpERLXwMhSOlwLKhsW_yc9TRp1Q6ezXdJc3EBgjxP05UMJWWu05J-HLnV69APal029b2w0e2Yja6NmMSpD79dvfnYMjkF389ra7QA

3. 启动proxy:

kubectl proxy

4. 访问并输入上面的token

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐