步骤
1 2 3 4 5 6 7 8 9 10 11 12 13
| mkdir key && cd key #生成证书 openssl genrsa -out dashboard.key 2048 openssl req -new -out dashboard.csr -key dashboard.key -subj '/CN=kubernetes-dashboard-certs' openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt #删除原有的证书 secret (sysin) kubectl delete secret kubernetes-dashboard-certs -n kube-system #创建新的证书 secret kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kube-system #查看 dashboard pod,v2.0 是 -n kubernetes-dashboard kubectl get pod -n kube-system #重启 dashboard pod,v2.0 是 -n kubernetes-dashboard kubectl delete pod -n kube-system
|
在部署 Dashboard 时手动创建证书
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| mkdir dashboard-certs
cd dashboard-certs/
#创建命名空间 kubectl create namespace kubernetes-dashboard
# 创建 key 文件 (sysin) openssl genrsa -out dashboard.key 2048
#证书请求,CN = 可修改为实际 IP 或者域名 openssl req -days 36000 -new -out dashboard.csr -key dashboard.key -subj '/CN=kubernetes-dashboard-certs'
#自签证书 openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt
#创建 kubernetes-dashboard-certs 对象 kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kubernetes-dashboard
|
备注:dashboard v2.0 namespace 是 kubernetes-dashboard
下载仅供下载体验和测试学习,不得商用和正当使用。
下载体验
点击下载