K8S 更换证书
下面操作都是在 master 中执行
查看当前证书到期时间
for item in `find /etc/kubernetes/pki -maxdepth 2 -name "*.crt"`;do openssl x509 -in $item -text -noout| grep Not;echo ======================$item===================;done
备份证书
cp -rp /etc/kubernetes /etc/kubernetes.bak
生成配置文件
kubeadm config view > /tmp/cluster.yaml
更新新证书
kubeadm alpha certs renew all --config=/tmp/cluster.yaml
重启相关服务
docker ps |grep -E 'k8s_kube-apiserver|k8s_kube-controller-manager|k8s_kube-scheduler|k8s_etcd_etcd' | awk -F ' ' '{print $1}' |xargs docker restart
查看新证书到期时间
for item in `find /etc/kubernetes/pki -maxdepth 2 -name "*.crt"`;do openssl x509 -in $item -text -noout| grep Not;echo ======================$item===============;done
更新配置文件
mv /root/.kube /root/.kube_20210107
mkdir /root/.kube/
cp -i /etc/kubernetes/admin.conf /root/.kube/config
检查
kubectl get node
参考:https://blog.csdn.net/qq_33235529/article/details/106053919