k8s install dashboard创建账户token(docker for windows)

2022-03-29 18:07:40 浏览数 (2)

docker for win10开启 k8s

k8s1.PNGk8s1.PNG

kubectl get service -n

1.下载所需yaml文件安装dashboard(可以直接下载文件)

代码语言:txt复制
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.0/aio/deploy/recommended.yaml

1.1修改 recommended.yaml

代码语言:txt复制
kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  type: NodePort            #第一个service下方修改类型
  ports:
    - port: 443
      targetPort: 8443
k2.PNGk2.PNG

2.登录dashboard

2.1.创建k8s管理员用户,默认用户管理权限太低,

代码语言:txt复制
PS C:UserslenovoprojectsDocker> kubectl create serviceaccount dashboard-admin -n kube-system

serviceaccount/dashboard-admin created

代码语言:txt复制
PS C:UserslenovoprojectsDocker> kubectl create clusterrolebinding dashboard-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:dashboard-admin

clusterrolebinding.rbac.authorization.k8s.io/dashboard-cluster-admin created

2.2.查找新创建用户token

代码语言:txt复制
PS C:UserslenovoprojectsDocker> kubectl get secrets -n kube-system
NAME                                             TYPE                                  DATA   AGE
attachdetach-controller-token-m76x2              kubernetes.io/service-account-token   3      11d
bootstrap-signer-token-gfs92                     kubernetes.io/service-account-token   3      11d
certificate-controller-token-nmssp               kubernetes.io/service-account-token   3      11d
clusterrole-aggregation-controller-token-9g52c   kubernetes.io/service-account-token   3      11d
coredns-token-85k6g                              kubernetes.io/service-account-token   3      11d
cronjob-controller-token-mpvzq                   kubernetes.io/service-account-token   3      11d
daemon-set-controller-token-s2tcd                kubernetes.io/service-account-token   3      11d
dashboard-admin-token-b4qcd                      kubernetes.io/service-account-token   3      38s
代码语言:txt复制
PS C:UserslenovoprojectsDocker> kubectl describe secrets -n kube-system  dashboard-admin-token-b4qcd
Name:         dashboard-admin-token-b4qcd
Namespace:    kube-system
Labels:       <none>
Annotations:  kubernetes.io/service-account.name: dashboard-admin
              kubernetes.io/service-account.uid: 695c329b-87d7-49a5-923d-fd4934523914

Type:  kubernetes.io/service-account-token

Data
====
ca.crt:     1099 bytes
namespace:  11 bytes
token:      eyJhbGciOiJSUzI1NiIsImtpZCI6Ik41eEMyOURSd2IwN1otMWZFWWhWRGUxd285aXRJTkR6cnlUNEpBNmxCRkUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tYjRxY2QiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiNjk1YzMyOWItODdkNy00OWE1LTkyM2QtZmQ0OTM0NTIzOTE0Iiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZC1hZG1pbiJ9.kwc63q3UMlUlLxn8zIRdvpcwGbrw5-9eKmr8exDB1dFp1R2EZUZ0WdNW0v_TaGwoiBwXYuBOI5vMhB3cAOQ5ZrK_jddz27t5D4AqIhssmm103fp5Bo57R5ipICDrXMu6TQJMkGg0O7FiFd2HURNYMg-PwbWDuu3uLjct4HxnE06EEvJ1uxwMdjxuXhlTZs3sxleGLJKqySScYxtnc9N2EQm-sJsb4MiuBuzXCRLh6f9GiEiR-erx2guzgpqDCa6tX5tFEZv25awdbvFUtOVIwql8tl8rUWgSVNAsDJvWBhibk80hk4H0TtGInkteWSDSJfrlwzb-dgoI-ABK44ohbQ
k3.PNGk3.PNG

3.然后可以使用dashboard创建容器,通过表单添加nginx容器

k4.PNGk4.PNG

访问容器nginx

k5.PNGk5.PNG

0 人点赞