# 移动到/tmp备份
/etc/kubernetes/ssl
{apiserver.crt,apiserver-etcd-client.key,apiserver-kubelet-client.crt,front-proxy-ca.crt,front-proxy-client.crt,front-proxy-client.key,front-proxy-ca.key,apiserver-kubelet-client.key,apiserver.key,apiserver-etcd-client.crt} /tmp
# 新生成证书,注意:参考文档1中用的是kubeadm alpha certs renew,这个不需要把源文件删除,目前用的是下面指令,renew方式未实践
# 备忘:采用kubeadm init phase certs 执行,是查看了kubesphere中安装脚本的执行参数,参考文档2里面提到保持安装时候kubeadm init的参数,之前折腾很久没恢复主要和参数有关
kubeadm init phase certs all --config /etc/kubernetes/kubeadm-config.yaml
# 新生成配置
cd /etc/kubernetes/
mv {admin.conf,controller-manager.conf,kubelet.conf,scheduler.conf} /tmp
kubeadm init phase kubeconfig all --config /etc/kubernetes/kubeadm-config.yaml
# 放置默认配置文件,否则kubectl执行会异常
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# 重启机器
init 6
# 复制master1生成的证书
scp -r master1IP:/etc/kubernetes/ssl/* /etc/kubernetes/ssl/
# 新生成配置
cd /etc/kubernetes/
mv {admin.conf,controller-manager.conf,kubelet.conf,scheduler.conf} /tmp
kubeadm init phase kubeconfig all --config /etc/kubernetes/kubeadm-config.yaml
# 重启机器
init 6
# 证书查看到期时间
openssl x509 -in /etc/kubernetes/ssl/apiserver.crt -text -noout |grep Not
覆盖本地kubeconf:
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
base64加密:
cat $HOME/.kube/config |base64
得到加密好的文字,使用sublime去掉换行符,得到最终的秘钥
更新HOST集群中的cluster配置
kubect edit cluster XXXX
替换掉
spec:
connection:
kubeconfig: