K8S master 节点IP变了导致访问失败
IP改变后,修复K8S
master node 26
原IP 10.115.193.68
新IP 10.115.193.25
# 这里使用sed批量替换
cd /etc/kubernetes/
# 先查
grep -rn '10.115.193' *
# 替换ip
sed -i 's/10.115.193.68/10.115.193.25/g' `grep -rl ./`
# 替换域名
# sed -i 's/local-115-193-68/cluster-endpoint/g' `grep -rl ./`
# 检查
grep -r '10.115.193' *
cd /etc/kubernetes
mv admin.conf admin.conf_bak
# 使用如下命令生成新的admin.conf
kubeadm init phase kubeconfig admin --apiserver-advertise-address 10.115.193.25
# 10.115.193.68-》10.115.193.25
sed -i 's/10.115.193.25/10.115.193.68/g' admin.conf
kubeadm init phase certs apiserver --apiserver-advertise-address 10.115.193.25 --apiserver-cert-extra-sans "10.115.193.25,node26"
执行后报错
E1013 11:58:55.849541 16907 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"https://10.115.193.25:6443/api?timeout=32s\": proxyconnect tcp: dial tcp 10.115.164.140:53128: connect: connection refused"
E1013 11:58:55.852444 16907 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"https://10.115.193.25:6443/api?timeout=32s\": proxyconnect tcp: dial tcp 10.115.164.140:53128: connect: connection refused"
E1013 11:58:55.855452 16907 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"https://10.115.193.25:6443/api?timeout=32s\": proxyconnect tcp: dial tcp 10.115.164.140:53128: connect: connection refused"
E1013 11:58:55.858218 16907 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"https://10.115.193.25:6443/api?timeout=32s\": proxyconnect tcp: dial tcp 10.115.164.140:53128: connect: connection refused"
E1013 11:58:55.861059 16907 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"https://10.115.193.25:6443/api?timeout=32s\": proxyconnect tcp: dial tcp 10.115.164.140:53128: connect: connection refused"
慌的一批
sudo -i
swapoff -a
exit
strace -eopenat kubectl version
执行最后4条命令后,突然就好了