小程序页面之间进行传值的操作办法
1170
2022-08-31
六、kubeadm证书过期更新
1. 使用说明
[root@k8s01 ~]# openssl x509 -in /etc/kubernetes/pki/ca.crt -noout -text |grep Not Not Before: Jan 10 09:56:12 2022 GMT Not After : Jan 8 09:56:12 2032 GMT[root@k8s01 ~]# openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -text |grep Not Not Before: Jan 10 09:56:12 2022 GMT Not After : Jan 10 09:56:13 2023 GMT#ca证书有效期10年,apiserver证书有效期1年kubeadm 生成的证书有效期为 1 年,该脚本可将 kubeadm 生成的证书有效期更新为 10 年该脚本只处理 master 节点上的证书,node 节点的 kubelet 证书默认自动轮换更新,无需关心过期问题,只需关心 master 节点上的证书即可该脚本仅需要在 master 节点执行,无需在 node 节点执行若没有 etcd 相关证书,只需要更新 master 证书即可,见这里(小于等于 v1.9 版本,etcd 默认不使用 TLS 连接)默认情况按照下面步骤进行证书更新执行时请使用 ./update-kubeadm-cert.sh all 或者 bash update-kubeadm-cert.sh all ,不要使用 sh update-kubeadm-cert.sh all,因为某些 Linux 发行版 sh 并不是链接到 bash,可能会不兼容如果有多个 master 节点,在每个 master 节点都执行一次执行命令:git clone update-kubeadm-certchmod 755 update-kubeadm-cert.shchmod 755 update-kubeadm-cert.sh./update-kubeadm-cert.sh all输出类似信息[2022-01-10T18:50:09.365346270+0800]: INFO: backup /etc/kubernetes to /etc/kubernetes.old-20220110Signature oksubject=/CN=etcd-serverGetting CA Private Key[2022-01-10T18:50:09.425352868+0800]: INFO: generated /etc/kubernetes/pki/etcd/server.crtSignature oksubject=/CN=etcd-peerGetting CA Private Key[2022-01-10T18:50:09.481460118+0800]: INFO: generated /etc/kubernetes/pki/etcd/peer.crtSignature oksubject=/O=system:masters/CN=kube-etcd-healthcheck-clientGetting CA Private Key[2022-01-10T18:50:09.522898903+0800]: INFO: generated /etc/kubernetes/pki/etcd/healthcheck-client.crtSignature oksubject=/O=system:masters/CN=kube-apiserver-etcd-clientGetting CA Private Key[2022-01-10T18:50:09.559751660+0800]: INFO: generated /etc/kubernetes/pki/apiserver-etcd-client.crt1c65dac2967f[2022-01-10T18:50:11.067593654+0800]: INFO: restarted etcdSignature oksubject=/CN=kube-apiserverGetting CA Private Key[2022-01-10T18:50:11.136289676+0800]: INFO: generated /etc/kubernetes/pki/apiserver.crtSignature oksubject=/O=system:masters/CN=kube-apiserver-kubelet-clientGetting CA Private Key[2022-01-10T18:50:11.177126464+0800]: INFO: generated /etc/kubernetes/pki/apiserver-kubelet-client.crtSignature oksubject=/CN=system:kube-controller-managerGetting CA Private Key[2022-01-10T18:50:11.269766849+0800]: INFO: generated /etc/kubernetes/controller-manager.crt[2022-01-10T18:50:11.302255202+0800]: INFO: generated new /etc/kubernetes/controller-manager.confSignature oksubject=/CN=system:kube-schedulerGetting CA Private Key[2022-01-10T18:50:11.379987827+0800]: INFO: generated /etc/kubernetes/scheduler.crt[2022-01-10T18:50:11.388350335+0800]: INFO: generated new /etc/kubernetes/scheduler.confSignature oksubject=/O=system:masters/CN=kubernetes-adminGetting CA Private Key[2022-01-10T18:50:11.454095179+0800]: INFO: generated /etc/kubernetes/admin.crt[2022-01-10T18:50:11.460446442+0800]: INFO: generated new /etc/kubernetes/admin.conf[2022-01-10T18:50:11.467249673+0800]: INFO: copy the admin.conf to ~/.kube/config for kubectl[2022-01-10T18:50:11.470375526+0800]: WARNING: does not need to update kubelet.confSignature oksubject=/CN=front-proxy-clientGetting CA Private Key[2022-01-10T18:50:11.502384189+0800]: INFO: generated /etc/kubernetes/pki/front-proxy-client.crt730fa1430c87[2022-01-10T18:50:12.428407360+0800]: INFO: restarted kube-apiserver4b97debc1405[2022-01-10T18:50:12.828963546+0800]: INFO: restarted kube-controller-manager8cbc7dd868e2[2022-01-10T18:50:13.409071339+0800]: INFO: restarted kube-scheduler[2022-01-10T18:50:13.625536997+0800]: INFO: restarted kubelet
2. 证书更新失败回滚
脚本会自动备份 /etc/kubernetes 目录到 /etc/kubernetes.old-$(date +%Y%m%d) 目录(备份目录命名示例:kubernetes.old-20200325)若更新证书失败需要回滚,手动将备份 /etc/kubernetes.old-$(date +%Y%m%d)目录覆盖 /etc/kubernetes 目录
3. 其他
以下内容与该脚本无关,只是啰嗦几句大于等于 v1.15 的版本可直接使用 kubeadm alpha certs renew
4、kubeadm 证书相关命令发展
v1.8 版开始提供了证书生成命令 kubeadm alpha phase certs
5、kubeadm 命令更新证书手动处理
使用该脚本更新证书,不涉及下面这个 bug,无需手动处理bug 见 ,这个bug 在 1.17 版修复针对小于 1.17版本 ,使用 kubeadm alpha certs renew
6、检查
[root@k8s01 ~]# openssl x509 -in /etc/kubernetes/pki/apiserver.crt -noout -text |grep Not Not Before: Jan 10 10:50:11 2022 GMT Not After : Jan 8 10:50:11 2032 GMT[root@k8s01 ~]# openssl x509 -in /etc/kubernetes/pki/apiserver-etcd-client.crt -noout -text |grep Not Not Before: Jan 10 10:50:09 2022 GMT Not After : Jan 8 10:50:09 2032 GMT[root@k8s01 ~]# openssl x509 -in /etc/kubernetes/pki/front-proxy-ca.crt -noout -text |grep Not Not Before: Jan 10 09:56:13 2022 GMT Not After : Jan 8 09:56:13 2032 GMT
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~