背景:现场搭建的单节点 rancher
问题:rancher的 ui 界面无法访问
排查:排查rancher容器日志报错time=“2021-12-29T08:27:32.616638402Z” level=info msg=“Waiting for master node startup: resource name may not be empty”
2021-12-29 08:27:32.985756 I | http: TLS handshake error from 127.0.0.1:35568: remote error: tls: bad certificate
time=“2021-12-29T08:27:32.987398748Z” level=error msg=“server https://127.0.0.1:6443/cacerts is not trusted: Get https://127.0.0.1:6443/cacerts: x509: certificate has expired or is not yet valid”
2021-12-29 08:27:32.987447 I | http: TLS handshake error from 127.0.0.1:35570: remote error: tls: bad certificate
time=“2021-12-29T08:27:33.620623487Z” level=info msg=“Waiting for master node startup: resource name may not be empty”
2021/12/29 08:27:34 [INFO] Waiting for server to become available: Get “https://127.0.0.1:6443/version?timeout=15m0s”: x509: certificate has expired or is not yet valid: current time 2021-12-29T08:27:34Z is after 2021-12-28T06:35:39
原因:单节点rancher默认证书是会自动更新的,2.5.7版本在更新证书这块存在bug,无法自动更换证书
解决:
1. 进入 rancher server 容器,执行相关操作
docker exec -it rancher /bin/sh
kubectl --insecure-skip-tls-verify -n kube-system delete secrets k3s-serving
kubectl --insecure-skip-tls-verify delete secret serving-cert -n cattle-system
rm -f /var/lib/rancher/k3s/server/tls/dynamic-cert.json
2. 请求刷新参数
curl --insecure -sfL https://localhost:8443/v3
3. 重启rancher server 容器
docker restart rancher
相关链接:https://docs.rancher.cn/docs/rancher2/cluster-admin/certificate-rotation/_index