關(guān)于這個(gè)問(wèn)題我已經(jīng)折騰幾周了,有空的時(shí)候搞一搞,試了有20次左右了吧,好多方式也嘗試了,今天使用kubectl proxy代理訪問(wèn)成功了?。∠旅嬗涗浺幌挛业牟襟E:
k8s版本:v1.12
k8s節(jié)點(diǎn)地址:10.0.60.51
生成證書(shū),導(dǎo)出的證書(shū)請(qǐng)導(dǎo)入到windows中。
#我使用的是ansible一鍵部署的證書(shū)在/etc/kubernetes/ssl/目錄下
openssl pkcs12 -export -in admin.pem -inkey admin-key.pem -certfile ca.pem -out kube-admin.p12
查看dashboard訪問(wèn)的地址
等會(huì)復(fù)制號(hào)6433端口號(hào)后面那串地址/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
[root@http ansible]# kubectl cluster-info
Kubernetes master is running at https://10.0.60.51:6443
CoreDNS is running at https://10.0.60.51:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
kubernetes-dashboard is running at https://10.0.60.51:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
在k8s節(jié)點(diǎn)上執(zhí)行kubectl proxy
[root@http ansible]# kubectl proxy --address='0.0.0.0' --port=8888 --accept-hosts='^*$'
在windows中訪問(wèn)dashboard,輸入的是代理端口號(hào)8888
http://10.0.60.51:8888/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy

image.png
查看token
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')