记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。

kubernetes集群证书一年后过期,如何续期


模拟证书过期

由kubeadm部署的集群,所生成的证书证书有效期为一年,过期之后集群就不能再次使用了,我们可以对证书进行续期,这样集群就可以继续使用

可以通过如下命令查看具体过期时间:

kubeadm alpha certs check-expiration

file

这里显示证书在2021年7月5日过期,然后把所有节点的系统时间调整到 2022年10月1日:

file

file

所有节点的时间都要调整。
然后在master(vms71上)执行kubectl命令:

[root@vms71 ~]# kubectl get nodes
Unable to connect to the server: x509: certificate has expired or is not yet valid
[root@vms71 ~]#

此时提醒证书已经过期。

对证书进行续期

用如下命令申请续期一年:
kubeadm alpha certs renew all

[root@vms71 ~]# kubeadm alpha  certs renew all
    ...输出...
certificate for the front proxy client renewed
certificate embedded in the kubeconfig file for the scheduler manager to use renewed
[root@vms71 ~]#

现在查看证书过期时间:
file
更新kubeconfig文件:
file

验证

验证集群是否可用:
file
已经可以继续使用了。查看集群过期时间:
file
过期时间已经到了2023年10月1日了。

 

 

再练习一次

再次把系统时间改成2025年10月1日(所有节点都改):

file

因为证书有效期是2023-10-01,现在是2025-10-01,所以证书是过期的:

file


跟前面的做法一样:再次用kubeadm alpha certs renew all对证书进行续期,然后重启kubelet,更新kubeconfig文件。
然后查看证书过期时间:

file

已经显示为2026年10月1日(当前是2025年10月1日),验证集群是否可用:

file



转载请标明出处【kubernetes集群证书一年后过期,如何续期】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论