2月
20
背景
如果你是通过rke安装kubernetes,并且rke版本在v0.2.0
之前,或者通过rancher安装,并且rancher版本在Rancher v2.0.14、v2.1.9
之前,默认的证书有效期是1年,这实在是个大坑,之后的版本rancher更改为10年,证书过期后对现有的服务不影响,服务依然能正常使用,但无法部署新的服务,并且api server不能提供服务,api server如果无法使用,集群基本就废了。
通过openssl工具查看证书有效期
openssl x509 -in /etc/kubernetes/ssl/kube-apiserver.pem -noout -dates notBefore=Jan 11 10:17:38 2019 GMT notAfter=Jan 11 10:17:39 2020 GMT
如果当前日期在notAfter之后,那么很不幸,你的证书过期了,此时kubectl命令不可用
$ kubectl get nodes Unable to connect to the server: x509: certificate has expired or is not yet valid
Read the rest of this entry