正常在用集群想要更换ip
master 节点ip192.168.10.138 改为192.168.10.148
node1节点ip192.168.10.139 改为192.168.10.149
node2节点ip192.168.10.140 改为192.168.10.150
master 节点
1)执行脚本1233.sh
1233.sh 内容如下:
# master 节点
export oldip1=192.168.10.138
export newip1=192.168.10.148
# node 节点
export oldip2=192.168.10.139
export newip2=192.168.10.149
export oldip3=192.168.10.140
export newip3=192.168.10.150
find /etc/kubernetes -type f | xargs sed -i "s/$oldip1/$newip1/"
find /etc/kubernetes -type f | xargs sed -i "s/$oldip2/$newip2/"
find /etc/kubernetes -type f | xargs sed -i "s/$oldip3/$newip3/"
find /root/.kube/config -type f | xargs sed -i "s/$oldip1/$newip1/"
echo "success 1111 full"
cd /root/.kube/cache/discovery
mv ${oldip1}_6443 ${newip1}_6443
echo "success 2222 full"
cd /etc/kubernetes/pki
mv apiserver.key apiserver.key.bak
mv apiserver.crt apiserver.crt.bak
kubeadm init phase certs apiserver --apiserver-advertise-address $newip1
systemctl restart kubelet
2)修改configmap
kubectl -n kube-system edit cm kube-proxy
老IP修改成新master IP地址
node 节点
记得修改每个node节点上 kubelet 配置文件IP
vi /etc/kubernetes/kubelet.conf
改成newip地址
systemctl restart kubelet
最后k8s集群所在的服务器重启2-3次,验证所有pod状态都正常。
标签:--,IP,192.168,apiserver,etc,export,newip1,集群,节点 From: https://www.cnblogs.com/vzhangxk/p/17751663.html