在k8s中的时间会提示证书过期问题,如
# kubectl get nodes Unable to connect to the server: x509: certificate has expired or is not yet valid
这里我们介绍一下续期方法。
注意:当前集群通过 kubeadm 命令创建。
kubeadm 安装得证书默认为 1 年,注意原证书文件必须保留在服务器上才能做延期操作,否则就会重新生成,集群可能无法恢复。
准备
这里先查看一下测试集群的证书过期时间
# kubeadm certs check-expiration [check-expiration] Reading configuration from the cluster... [check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml' CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED admin.conf Aug 30, 2022 03:18 UTC 324d no apiserver Aug 30, 2022 03:18 UTC 324d ca no apiserver-etcd-client Aug 30, 2022 03:18 UTC 324d etcd-ca no apiserver-kubelet-client Aug 30, 2022 03:18 UTC 324d ca no controller-manager.conf Aug 30, 2022 03:18 UTC 324d no etcd-healthcheck-client Aug 30, 2022 03:18 UTC 324d etcd-ca no etcd-peer Aug 30, 2022 03:18 UTC 324d etcd-ca no etcd-server Aug 30, 2022 03:18 UTC 324d etcd-ca no front-proxy-client Aug 30, 2022 03:18 UTC 324d front-proxy-ca no scheduler.conf Aug 30, 2022 03:18 UTC 324d no CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED ca Aug 28, 2031 03:18 UTC 9y no etcd-ca Aug 28, 2031 03:18 UTC 9y no front-proxy-ca Aug 28, 2031 03:18 UTC 9y no
可以看到过期时间为 2022-08-30。
Continue reading