一、生成訪問證書git
grep 'client-certificate-data' ~/.kube/config | head -n 1 | awk '{print $2}' | base64 -d >> kubecfg.crt grep 'client-key-data' ~/.kube/config | head -n 1 | awk '{print $2}' | base64 -d >> kubecfg.key openssl pkcs12 -export -clcerts -inkey kubecfg.key -in kubecfg.crt -out kubecfg.p12 -name "kubernetes-client"
將生成的kubecfg.p12證書導入到Windows中,直接雙擊打開,下一步導入便可。github
注意:導入完成後需重啓瀏覽器。api
二、生成訪問Token瀏覽器
新建文件admin-user.yaml:app
apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kube-system --- apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: admin-user roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: admin-user namespace: kube-system
建立角色及綁定帳號curl
kubectl create -f admin-user.yaml
獲取Tokengoogle
kubectl describe secret admin-user --namespace=kube-system
這次先記錄下生成的Tokenurl
三、部署kubernetes-dashboardspa
curl -o kubernetes-dashboard.yaml https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml vi kubernetes-dashboard.yaml 修改image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1爲: image: mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.1 kubectl apply -f kubernetes-dashboard.yaml
四、訪問code
https://192.170.38.92:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
192.170.38.92爲MasterIP,6443爲apiserver-port
而後在登陸選項中選擇令牌登陸,複製進剛剛生成的令牌便可。