使用 kubeadm 进行证书管理
  1m9rJBpbaLoS 2023年11月30日 20 0

检查证书是否过期

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                 Nov 11, 2024 07:10 UTC   362d            ca                      no      
apiserver                  Nov 11, 2024 07:10 UTC   362d            ca                      no      
apiserver-etcd-client      Nov 11, 2024 07:10 UTC   362d            etcd-ca                 no      
apiserver-kubelet-client   Nov 11, 2024 07:10 UTC   362d            ca                      no      
controller-manager.conf    Nov 11, 2024 07:10 UTC   362d            ca                      no      
etcd-healthcheck-client    Nov 11, 2024 07:10 UTC   362d            etcd-ca                 no      
etcd-peer                  Nov 11, 2024 07:10 UTC   362d            etcd-ca                 no      
etcd-server                Nov 11, 2024 07:10 UTC   362d            etcd-ca                 no      
front-proxy-client         Nov 11, 2024 07:10 UTC   362d            front-proxy-ca          no      
scheduler.conf             Nov 11, 2024 07:10 UTC   362d            ca                      no      

CERTIFICATE AUTHORITY   EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED
ca                      Nov 09, 2033 07:10 UTC   9y              no      
etcd-ca                 Nov 09, 2033 07:10 UTC   9y              no      
front-proxy-ca          Nov 09, 2033 07:10 UTC   9y              no
上面的列表中没有包含 kubelet.conf,因为 kubeadm 将 kubelet 配置为自动更新证书。 轮换的证书位于目录 /var/lib/kubelet/pki。

更新证书

生成证书

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.

更新配置文件

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

重启 kubelet 服务

# systemctl restart kubelet

参考文档

https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月30日 0

暂无评论

推荐阅读
1m9rJBpbaLoS