通過kubeadm快速完成了kubernetes的安裝,即可迅速地體驗(yàn)到kubernetes的強(qiáng)大功能。美中不足的是,只能通過命令來查看或操作,沒有一個(gè)直觀且簡潔的Web UI來感受一下這種成功的喜悅。此外,國內(nèi)的網(wǎng)絡(luò)環(huán)境,也在某種程度上增加了一些門檻。面對如此種種,依然有辦法體驗(yàn)kunernetes dashboard。
為寧鄉(xiāng)等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及寧鄉(xiāng)網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、寧鄉(xiāng)網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
因?yàn)椴磺宄od會(huì)被調(diào)度到哪一個(gè)Node上,所以在每一個(gè)節(jié)點(diǎn)上執(zhí)行以下腳本:
#!/bin/bash
docker pull registry.cn-qingdao.aliyuncs.com/wangxiaoke/kubernetes-dashboard-amd64:v1.10.0
# docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.10.0
docker tag registry.cn-qingdao.aliyuncs.com/wangxiaoke/kubernetes-dashboard-amd64:v1.10.0 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0
docker image rm registry.cn-qingdao.aliyuncs.com/wangxiaoke/kubernetes-dashboard-amd64:v1.10.0
在Master節(jié)點(diǎn)上執(zhí)行:
[root@k8s-m ~]# curl -O kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml
[root@k8s-m ~]# kubectl apply -f kubernetes-dashboard.yaml
查看pod是否創(chuàng)建成功:
[root@k8s-m ~]# kubectl get pods --namespace=kube-system
NAME READY STATUS RESTARTS AGE
coreDNS-576cbf47c7-xg4xm 1/1 Running 1 72m
coredns-576cbf47c7-xq9mc 1/1 Running 1 80m
etcd-k8s-m 1/1 Running 2 79m
kube-apiserver-k8s-m 1/1 Running 2 79m
kube-controller-manager-k8s-m 1/1 Running 21 80m
kube-flannel-ds-amd64-9fzm7 1/1 Running 1 72m
kube-flannel-ds-amd64-nddqf 1/1 Running 2 72m
kube-proxy-6js29 1/1 Running 2 80m
kube-proxy-lp2v2 1/1 Running 2 72m
kube-scheduler-k8s-m 1/1 Running 19 80m
kubernetes-dashboard-77fd78f978-ngkvb 1/1 Running 1 25m
修改service配置,找到type,將ClusterIP改成NodePort:
[root@k8s-m ~]# kubectl edit service kubernetes-dashboard --namespace=kube-system
查看暴露端口:
[root@k8s-m ~]# kubectl get service --namespace=kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns ClusterIP 10.96.0.10 53/UDP,53/TCP 87m
kubernetes-dashboard NodePort 10.101.204.129 443:31269/TCP 32m
創(chuàng)建kubernetes-dashboard用戶:
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: admin
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: admin
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
創(chuàng)建用戶:
[root@k8s-m ~]# kubectl create -f admin-token.yaml
獲取登錄token:
[root@k8s-m ~]# kubectl get secret -n kube-system |grep admin|awk '{print $1}'
admin-token-6tkxm
[root@k8s-m ~]# kubectl describe secret admin-token-6tkxm -n kube-system|grep '^token'|awk '{print $2}'
eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi10b2tlbi02dGt4bSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJhZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjQ4MjcxNTE5LTFkODgtMTFlOS1iMGZkLTAwMTU1ZDc0ZWUyNyIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTphZG1pbiJ9.TpBGEd-7VXrYjN_5fi0sOXMqLIrhDkgqIVVTagO4wvKOQloCJkpfvnVgBJ0Oi52-UQNBKBVH8v1wRBltPHKrjMqVU9re6-y3nd4UbwWtIZzmfMJ_oRwo2ne_UdU_Ya2I5EOH3qh2cUIhdG3NpZYXwFICsNZURJWZM_U7OqJrZPuMXw4sfD6iGRWeMtOiAI8YN1LAfpj1RHaeOa66DK_LEsSLBsb2W6m7wrugk7SBCJSkMyec7ZVGLHo5Ha-X5wNO5qAAKzud0lz2KVcvwJW8lkcc9_lPxPIoDIpdCFEoG5xZHr0B2PkatCS8f31VQzP6LAmvkmHxbENb6V3Ov90RGw
將以上內(nèi)容復(fù)制備用。
3.1 打開瀏覽器輸入訪問地址:
3.2 認(rèn)證方式選擇口令,輸入剛才獲取到的token,即可登陸成功。
3.3 登錄成功后,如下圖:
4.1 這是一個(gè)簡單而快樂的過程,只要?jiǎng)邮秩プ觯鋵?shí)很簡單的!
4.2 這次實(shí)驗(yàn)是部署在kubernetes v1.12.1的。
4.3 實(shí)驗(yàn)使用的瀏覽器是Firefox v64.0.2,其他瀏覽器可能不支持。