您好,登錄后才能下訂單哦!
內容要點:
1、環境介紹
2、web界面部署
一、環境介紹:
1、此篇作為k8s群集部署的最后一步,前幾步博客地址:
kubernetes二進制集群部署一——etcd存儲組件、flannel網絡組件部署:
kubernetes二進制集群部署二——單master集群部署+多master群及部署:
kubernetes二進制集群部署三——負載均衡調度器部署:
2、dashborad 官方文件地址:https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/dashboard
二、web界面部署:
?在?master01上操作: //創建?dashborad(控制面板)工作目錄: [root@localhost?k8s]#?mkdir?dashboard //拷貝官方文件(總共6個): [root@localhost?dashboard]#?ls?? dashboard-configmap.yaml???dashboard-rbac.yaml????dashboard-service.yaml dashboard-controller.yaml??dashboard-secret.yaml??k8s-admin.yaml //加載、創建所有的文件: [root@localhost?dashboard]#?kubectl?create?-f?dashboard-rbac.yaml role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal?created rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal?created [root@localhost?dashboard]#?kubectl?create?-f?dashboard-secret.yaml secret/kubernetes-dashboard-certs?created secret/kubernetes-dashboard-key-holder?created [root@localhost?dashboard]#?kubectl?create?-f?dashboard-configmap.yaml configmap/kubernetes-dashboard-settings?created [root@localhost?dashboard]#?kubectl?create?-f?dashboard-controller.yaml serviceaccount/kubernetes-dashboard?created deployment.apps/kubernetes-dashboard?created [root@localhost?dashboard]#?kubectl?create?-f?dashboard-service.yaml service/kubernetes-dashboard?created //完成創建后查看創建在指定的?kube-system命名空間下: [root@localhost?dashboard]#?kubectl?get?pods?-n?kube-system NAME????????????????????????????????????READY???STATUS????RESTARTS???AGE kubernetes-dashboard-65f974f565-rs2h5???1/1?????Running???0??????????4m23s //查看如何訪問: [root@localhost?dashboard]#?kubectl?get?pods,svc?-n?kube-system NAME????????????????????????????????????????READY???STATUS????RESTARTS???AGE pod/kubernetes-dashboard-65f974f565-x9vrg???1/1?????Running???0??????????8m32s NAME???????????????????????????TYPE???????CLUSTER-IP???EXTERNAL-IP???PORT(S)?????????AGE service/kubernetes-dashboard???NodePort???10.0.0.110???<none>????????443:30001/TCP???8m18s
此時,我們用谷歌瀏覽器訪問:https://192.168.109.131:30001/
原因:沒有自簽證書
如何解決:寫一個證書
在?master01上: [root@localhost?dashboard]#?vim?dashboard-cert.sh cat?>?dashboard-csr.json?<<EOF { ???"CN":?"Dashboard", ???"hosts":?[], ???"key":?{ ???????"algo":?"rsa", ???????"size":?2048 ???}, ???"names":?[ ???????{ ???????????"C":?"CN", ???????????"L":?"BeiJing", ???????????"ST":?"BeiJing" ???????} ???] } EOF K8S_CA=$1 cfssl?gencert?-ca=$K8S_CA/ca.pem?-ca-key=$K8S_CA/ca-key.pem?-config=$K8S_CA/ca-config.json?-profile=kubernetes?dashboard-csr.json?|?cfssljson?-bare?dashboard kubectl?delete?secret?kubernetes-dashboard-certs?-n?kube-system kubectl?create?secret?generic?kubernetes-dashboard-certs?--from-file=./?-n?kube-system //接下來,就是生成證書: [root@localhost?dashboard]#?bash?dashboard-cert.sh?/root/k8s/k8s-cert/ [root@localhost?dashboard]#?vim?dashboard-controller.yaml 在?args目錄下,添加證書的路徑: ... (省略內容) ... args: ??????????#?PLATFORM-SPECIFIC?ARGS?HERE ??????????-?--auto-generate-certificates ??????????-?--tls-key-file=dashboard-key.pem ??????????-?--tls-cert-file=dashboard.pem ... (省略內容) ...
//接下來,進行重新部署: [root@localhost?dashboard]#??kubectl?apply?-f?dashboard-controller.yaml? Warning:?kubectl?apply?should?be?used?on?resource?created?by?either?kubectl?create?--save-config?or?kubectl?apply serviceaccount/kubernetes-dashboard?configured Warning:?kubectl?apply?should?be?used?on?resource?created?by?either?kubectl?create?--save-config?or?kubectl?apply deployment.apps/kubernetes-dashboard?configured
然后,我們再次訪問剛剛的那個網站:https://192.168.220.136:30001/
選擇接受風險并繼續,選擇令牌:
接下來,我們要做的就是生成令牌,在瀏覽器中填入即可:
//生成令牌: [root@localhost?dashboard]#?kubectl?create?-f?k8s-admin.yaml //保存: [root@localhost?dashboard]#?kubectl?get?secret?-n?kube-system NAME???????????????????????????????TYPE??????????????????????????????????DATA???AGE dashboard-admin-token-829rp????????kubernetes.io/service-account-token???3??????9s default-token-rsrxp????????????????kubernetes.io/service-account-token???3??????3h20m kubernetes-dashboard-certs?????????Opaque????????????????????????????????11?????12m kubernetes-dashboard-key-holder????Opaque????????????????????????????????2??????119m kubernetes-dashboard-token-6rdlf???kubernetes.io/service-account-token???3??????118m //查看令牌: [root@localhost?dashboard]#?kubectl?describe?secret?dashboard-admin-token-829rp?-n?kube-system
而下面,就是生成令牌的一段密文:
我們把這段密文復制,然后粘貼到,瀏覽器上面的空白處即可:
然后,我們可以在控制面板上,管理我們的各個組件,查看各類信息和概況等等,非常的方便
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。