1:在master节点上执行:
kubeadm certs renew all
2:按照提示,查找kube-apiserver, kube-controller-manager, kube-scheduler and etcd服务的容器并重启:
docker ps | grep -E 'kube-apiserver|kube-controller-manager|kube-scheduler|etcd'
3:根据上一步查到的容器id重启docker容器:
4:至此,证书更新完毕,重新执行kubectl命令,可能提示“error: You must be logged in to the server (Unauthorized)”
处理方法:
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
再使环境变量生效:
source ~/.bash_profile
即可解决问题。