手动续订 kubeadm 管理的证书
问题
Kubeadm 管理的证书在部署后一年后过期。当证书过期时,Pod 无法启动并在日志中显示错误的证书错误。
解决 方案
Paragon Automation Kubernetes 集群使用自生成的 kubeadm 托管证书。这些证书在部署后一年内过期,除非升级 Kubernetes 版本或手动续订证书。
请按照以下步骤手动续订证书:
-
在群集的每个主节点上使用命令检查
kubeadm certs check-expiration
当前的证书到期日期。root@primary1-node:~# 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 Dec 13, 2023 13:20 UTC 328d no apiserver Dec 13, 2023 13:20 UTC 328d ca no apiserver-etcd-client Dec 13, 2023 13:20 UTC 328d etcd-ca no apiserver-kubelet-client Dec 13, 2023 13:20 UTC 328d ca no controller-manager.conf Dec 13, 2023 13:20 UTC 328d no etcd-healthcheck-client Dec 13, 2023 13:20 UTC 328d etcd-ca no etcd-peer Dec 13, 2023 13:20 UTC 328d etcd-ca no etcd-server Dec 13, 2023 13:20 UTC 328d etcd-ca no front-proxy-client Dec 13, 2023 13:20 UTC 328d front-proxy-ca no scheduler.conf Dec 13, 2023 13:20 UTC 328d no CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED ca Nov 27, 2032 21:31 UTC 9y no etcd-ca Nov 27, 2032 21:31 UTC 9y no front-proxy-ca Nov 27, 2032 21:31 UTC 9y no
-
要续订证书,请在 Kubernetes 群集的每个主节点上使用
kubeadm certs renew all
命令。root@primary1-node:~# 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' 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.
-
在群集的每个主节点上使用命令重新
kubeadm certs check-expiration
检查到期日期。root@primary1-node:~# 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 Jan 18, 2024 21:40 UTC 364d no apiserver Jan 18, 2024 21:40 UTC 364d ca no apiserver-etcd-client Jan 18, 2024 21:40 UTC 364d etcd-ca no apiserver-kubelet-client Jan 18, 2024 21:40 UTC 364d ca no controller-manager.conf Jan 18, 2024 21:40 UTC 364d no etcd-healthcheck-client Jan 18, 2024 21:40 UTC 364d etcd-ca no etcd-peer Jan 18, 2024 21:40 UTC 364d etcd-ca no etcd-server Jan 18, 2024 21:40 UTC 364d etcd-ca no front-proxy-client Jan 18, 2024 21:40 UTC 364d front-proxy-ca no scheduler.conf Jan 18, 2024 21:40 UTC 364d no CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED ca Nov 27, 2032 21:31 UTC 9y no etcd-ca Nov 27, 2032 21:31 UTC 9y no front-proxy-ca Nov 27, 2032 21:31 UTC 9y no
-
从任何一个主节点重新启动以下 Pod 以使用新证书。
root@primary1-node:~# kubectl delete pod -n kube-system -l component=kube-apiserver root@primary1-node:~# kubectl delete pod -n kube-system -l component=kube-scheduler root@primary1-node:~# kubectl delete pod -n kube-system -l component=kube-controller-manager root@primary1-node:~# kubectl delete pod -n kube-system -l component=etcd