系列目錄html
前面一節咱們介紹瞭如何使用kube-proxy
搭建代理訪問dashboard,這樣作缺點很是明顯,第一能夠經過http訪問,第二是這種方式要啓動一個後臺進程,若是進程關閉了則不可以訪問了,還須要手動開啓proxy.另一個問題就是可能有部分讀者已經遇到了,在輸入token的時候,web界面無影響,筆者在本機試的時候經過firefox無響應,經過谷歌瀏覽器有時候無響應,有時候偶爾會有響應.下面經過使用api-server地址來訪問dashboard.web
mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
注,此步驟也能夠不要,只是如下的操做步驟用到
$HOME/.kube/config
都要換成/etc/kubernetes/admin.conf
,這裏是參照了這篇文章,我就和做者保持一致.windows
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這一步須要輸入密碼,以供之後導入時使用centos
[root@k8s-master key]# openssl pkcs12 -export -clcerts -inkey kubecfg.key -in kubecfg.crt -out kubecfg.p12 -name "kubernetes-client" Enter Export Password:
這裏輸入密碼,這裏是設置密碼,所以能夠輸入你本身方便管理的密碼,輸入完之後要求再次確認,確認完之後就會生成一個kubecfg.p12
文件.完成之後咱們把kubecfg.p12
複製到要訪問dashboard的機器上,若是是windows機,則雙擊這個文件,會彈出一個安裝嚮導,須要輸入咱們剛纔設置的密碼,輸入完之後一直下一步就好了.api
執行完以上操做後,打開谷歌內核
瀏覽器,輸入https://192.168.124.59:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:https/proxy
就能夠不用搭建proxy來訪問dashboard了.(訪問的時候瀏覽器會出現一個提示,讓選擇證書,點擊確證就行了)瀏覽器
目前使用火狐會出現403 forbidden現象,切換到谷歌就好了bash
有的童鞋跟着以上操做可能最終也成功了,可是一臉懵,爲何要這樣操做.這個地址又是哪來的,我要用記事本把這一長串地址保存起來麼?spa
實際上以上dashboard是經過kubectl cluster-info
命令獲取到的firefox
[centos@k8s-master dashboard]$ kubectl cluster-info Kubernetes master is running at https://192.168.124.59:6443 KubeDNS is running at https://192.168.124.59:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy kubernetes-dashboard is running at https://192.168.124.59:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:https/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. [centos@k8s-master dashboard]$
設置證書是由於這個地址是https地址,須要生成證書來訪問.debug