k8s dashboard token

1.下载dashboard.yaml 文件

wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

2.修改为nodePort,外网访问.


k8s dashboard token_第1张图片

3. 部署

kubectl apply -f kubernetes-dashboard.yaml

4.访问权限

[root@k8s-master ~]# cat user-admin.yaml

# ------------------- ServiceAccount ------------------- #

apiVersion: v1

kind: ServiceAccount

metadata:

  name: user-admin

  namespace: kube-system

---

# ------------------- ClusterRoleBinding ------------------- #

apiVersion: rbac.authorization.k8s.io/v1beta1

kind: ClusterRoleBinding

metadata:

  name: user-admin

roleRef:

  apiGroup: rbac.authorization.k8s.io

  kind: ClusterRole

  name: cluster-admin

subjects:

- kind: ServiceAccount

  name: user-admin

  namespace: kube-system

5. 部署

kubectl apply -f user-admin.yaml

6. 查看token

[root@k8s-master ~]# kubectl -n kube-system get secret | grep user-admin

user-admin-token-dlztr kubernetes.io/service-account-token 3 12m

[root@k8s-master ~]# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep user-admin | awk '{print $1}')

Name: user-admin-token-dlztr

Namespace: kube-system

Labels:

Annotations: kubernetes.io/service-account.name=user-admin

                      kubernetes.io/service-account.uid=42911c5c-1abb-11e8-9497-525400dd4c85

Type:  kubernetes.io/service-account-token

Data

====

ca.crt:    1025 bytes

namespace:  11 bytes

token:      eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJ1c2VyLWFkbWluLXRva2VuLWRsenRyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6InVzZXItYWRtaW4iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI0MjkxMWM1Yy0xYWJiLTExZTgtOTQ5Ny01MjU0MDBkZDRjODUiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06dXNlci1hZG1pbiJ9.qOKBgKhpuQX40LsWpQk9IStJ3Hg6-1r56H80t9h-17jZsqQpp00ZBtr4g32XsonuUkMDrh1PwKe-0u2zOWOletHNICoebvXg6k6E7yJ1SsfY0kiXsq4yxEeR7qjVV-1BpyHBdFWH2r-EGGW2jTRgRnnkZ4bqYSRA3igXGBkG7ezQCL0zLqS92Wrc24ANgzcovHvMcKodL-e205gyZtYiAc06Z0BQdDZuZ67VqwFLr5Xzfr6vPhYaf4oNbuv2o2CfI-Brm7DOsu2IjmFHLygYdD99jo-5ZArlUOVWQdze7cR7NHTfPZ-hovA3gSms_k31OFCALDHm6FLlBvNPlssvNw

你可能感兴趣的:(k8s dashboard token)