Термін дії сертифікатів, керованих kubeadm, закінчується через рік після розгортання.
Якщо при отриманні даних із кластера наприклад командою kubectl get pods -n kube-system
видає:
Unable to connect to the server: tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 2024-07-22T17:11:50+03:00 is after 2024-07-20T16:14:05Z
то проблема у сертифікатах.
kubeadm certs check-expiration
- перевірте поточну дату закінчення терміну дії сертифікатів на кожній control-plane,master
ноді.
у відповідь отримаємо:
[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 Jul 20, 2024 16:11 UTC <invalid> ca no
apiserver Jul 20, 2024 16:11 UTC <invalid> ca no
apiserver-etcd-client Jul 20, 2024 16:11 UTC <invalid> etcd-ca no
apiserver-kubelet-client Jul 20, 2024 16:11 UTC <invalid> ca no
controller-manager.conf Jul 20, 2024 16:12 UTC <invalid> ca no
etcd-healthcheck-client Jul 20, 2024 16:11 UTC <invalid> etcd-ca no
etcd-peer Jul 20, 2024 16:11 UTC <invalid> etcd-ca no
etcd-server Jul 20, 2024 16:11 UTC <invalid> etcd-ca no
front-proxy-client Jul 20, 2024 16:11 UTC <invalid> front-proxy-ca no
scheduler.conf Jul 20, 2024 16:12 UTC <invalid> ca no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Jul 15, 2033 12:30 UTC 8y no
etcd-ca Jul 15, 2033 12:30 UTC 8y no
front-proxy-ca Jul 15, 2033 12:30 UTC 8y no
Щоб оновити сертифікати, використовуйте команду kubeadm certs renew all
на кожному control-plane,master
вузлі вашого кластера Kubernetes.
При виконанні 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.
Ще раз перевірте дату закінчення терміну дії за допомогою команди kubeadm certs check-expiration
на кожному основному вузлі вашого кластера.
Відповідь буде:
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED
admin.conf Jul 22, 2025 14:49 UTC 364d ca no
apiserver Jul 22, 2025 14:49 UTC 364d ca no
apiserver-etcd-client Jul 22, 2025 14:49 UTC 364d etcd-ca no
apiserver-kubelet-client Jul 22, 2025 14:49 UTC 364d ca no
controller-manager.conf Jul 22, 2025 14:49 UTC 364d ca no
etcd-healthcheck-client Jul 22, 2025 14:49 UTC 364d etcd-ca no
etcd-peer Jul 22, 2025 14:49 UTC 364d etcd-ca no
etcd-server Jul 22, 2025 14:49 UTC 364d etcd-ca no
front-proxy-client Jul 22, 2025 14:49 UTC 364d front-proxy-ca
scheduler.conf Jul 22, 2025 14:49 UTC 364d ca no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
ca Jul 15, 2033 12:30 UTC 8y no
etcd-ca Jul 15, 2033 12:30 UTC 8y no
front-proxy-ca Jul 15, 2033 12:30 UTC 8y no
Перезапустіть наступні поди з будь-якого з основних вузлів, щоб використовувати нові сертифікати
kubectl delete pod -n kube-system -l component=kube-apiserver
kubectl delete pod -n kube-system -l component=kube-scheduler
kubectl delete pod -n kube-system -l component=kube-controller-manager
kubectl delete pod -n kube-system -l component=etcd
Відобразити перезапущені pods
kubectl get pods -n kube-system
Переглянути логі:
kubectl logs <pod_name> -n kube-system