问题
kubeadm 安装的集群默认签发的证书有效期为1年,到期后集群组件之间无法正常通信。
证书修复流程
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'
[check-expiration] Error reading configuration from the Cluster. Falling back to default configuration
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Feb 16, 2024 14:06 UTC <invalid> no
apiserver Jul 01, 2024 07:38 UTC 25d ca no
apiserver-etcd-client Feb 16, 2024 14:06 UTC <invalid> etcd-ca no
apiserver-kubelet-client Feb 16, 2024 14:06 UTC <invalid> ca no
controller-manager.conf Feb 16, 2024 14:06 UTC <invalid> no
etcd-healthcheck-client Feb 16, 2024 14:06 UTC <invalid> etcd-ca no
etcd-peer Feb 16, 2024 14:06 UTC <invalid> etcd-ca no
etcd-server Feb 16, 2024 14:06 UTC <invalid> etcd-ca no
front-proxy-client Feb 16, 2024 14:06 UTC <invalid> front-proxy-ca no
scheduler.conf Feb 16, 2024 14:06 UTC <invalid> no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Feb 13, 2033 14:06 UTC 8y no
etcd-ca Feb 13, 2033 14:06 UTC 8y no
front-proxy-ca Feb 13, 2033 14:06 UTC 8y no
2. 重新签发证书
$ kubeadm certs renew all
[renew] Reading configuration from the cluster...
[renew] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[renew] Error reading configuration from the Cluster. Falling back to default configuration
certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed
certificate for serving the Kubernetes API renewed
certificate the apiserver uses to access etcd renewed
certificate for the API server to connect to kubelet renewed
certificate embedded in the kubeconfig file for the controller manager to use renewed
certificate for liveness probes to healthcheck etcd renewed
certificate for etcd nodes to communicate with each other renewed
certificate for serving etcd renewed
certificate for the front proxy client renewed
certificate embedded in the kubeconfig file for the scheduler manager to use renewed
Done renewing certificates. You must restart the kube-apiserver, kube-controller-manager, kube-scheduler and etcd, so that they can use the new certificates.
3. 重启控制面组件
由于控制面组件是由静态pod方式启动,重启kubelet即可重启所有静态pod组件
systemctl restart kubelet
重新检查有效期:
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 Jun 06, 2025 03:10 UTC 364d no
apiserver Jun 06, 2025 03:10 UTC 364d ca no
apiserver-etcd-client Jun 06, 2025 03:10 UTC 364d etcd-ca no
apiserver-kubelet-client Jun 06, 2025 03:10 UTC 364d ca no
controller-manager.conf Jun 06, 2025 03:10 UTC 364d no
etcd-healthcheck-client Jun 06, 2025 03:10 UTC 364d etcd-ca no
etcd-peer Jun 06, 2025 03:10 UTC 364d etcd-ca no
etcd-server Jun 06, 2025 03:10 UTC 364d etcd-ca no
front-proxy-client Jun 06, 2025 03:10 UTC 364d front-proxy-ca no
scheduler.conf Jun 06, 2025 03:10 UTC 364d no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Feb 13, 2033 14:06 UTC 8y no
etcd-ca Feb 13, 2033 14:06 UTC 8y no
front-proxy-ca Feb 13, 2033 14:06 UTC 8y no
标签:UTC,06,no,过期,ca,证书,etcd,Feb,k8s
From: https://www.cnblogs.com/f66666/p/18234867