环境
k8s version: v.1.16.3
dashboard: dashboard:v2.0.0-beta6
问题描述
K8S Dashboard安装好以后,通过Firefox浏览器是可以打开的,但通过Google Chrome浏览器,无法成功浏览页面。如图:
kubeadm自动生成的证书,很多浏览器不支持。所以我们需要自己创建证书。
创建一个目录
存放证书等文件
mkdir key
cd key
生成证书
openssl genrsa -out dashboard.key 2048
Generating RSA private key, 2048 bit long modulus
.................+++
......+++
e is 65537 (0x10001)
172.16.64.229为master节点的IP地址
openssl req -new -out dashboard.csr -key dashboard.key -subj '/CN=172.16.64.229'
openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt
Signature ok
subject=/CN=172.16.64.229
Getting Private key
删除原有证书
注意新版的Dashboard的namespace已经变为kubernetes-dashboard了
kubectl delete secret kubernetes-dashboard-certs -n kubernetes-dashboard
secret "kubernetes-dashboard-certs" deleted
创建新证书的secret
kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kubernetes-dashboard
secret/kubernetes-dashboard-certs created
查找正在运行的pod
kubectl get pod -n kubernetes-dashboard
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-76585494d8-dzgt9 1/1 Running 0 8m20s
kubernetes-dashboard-b65488c4-rcdjh 1/1 Running 0 8m20s
删除pod
kubectl delete po kubernetes-dashboard-b65488c4-rcdjh -n kubernetes-dashboard
pod "kubernetes-dashboard-b65488c4-rcdjh" deleted
kubectl delete po dashboard-metrics-scraper-76585494d8-dzgt9 -n kubernetes-dashboard
pod "dashboard-metrics-scraper-76585494d8-dzgt9" deleted
如果pod比较多的时候,可以使用以下这条命令批量删除。
kubectl get pod -n kubernetes-dashboard | grep -v NAME | awk '{print "kubectl delete po " $1 " -n kubernetes-dashboard"}' | sh
删除后,新的pod会自动启动起来。
这时,再次刷新Chrome浏览器的Dashboard页面,如图:
点击继续前往
,页面就可以正常显示了。
发表评论
共 0 条评论
暂无评论