有时候由于服务器的调整,导致ip的的变化,k8s集群的api大管家的ip变动会导致kubectl的接口都无法正常使用,这是只需要将k8s主节点配置文件的ip替换即可。
例如无需要将原来的192.168.146.202的ip替换成192.168.85.202,执行一下操作即可
一、替换的ip
替换kube-apiserver.yaml和etcd.yaml
sed -i 's/192.168.146.202/192.168.85.200/g' /etc/kubernetes/manifests/kube-apiserver.yaml
sed -i 's/192.168.146.202/192.168.85.200/g' /etc/kubernetes/manifests/etcd.yaml
二、生成新的conf文件
kubeadm init phase kubeconfig admin --apiserver-advertise-address 192.168.85.202
kubeadm init phase kubeconfig controller-manager --apiserver-advertise-address 192.168.85.202
kubeadm init phase kubeconfig kubelet --apiserver-advertise-address 192.168.85.202
kubeadm init phase kubeconfig scheduler --apiserver-advertise-address 192.168.85.202
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
三、生成apiserver证书文件
重新生成apiserver.key 、apiserver.crt证书
kubeadm init phase certs apiserver --apiserver-advertise-address 192.168.85.202
四、重启apiserver
systemctl restart kube-apiserer