Forum Navigation
You need to log in to create posts and topics.

Kubernetes Change Master Node IP Address

Problem

IP address of Master node changed and now cluster can’t restart

 

Solution

Run the following commands to fix the issue

systemctl stop kubelet docker
cd /etc/
# backup old kubernetes data
mv kubernetes kubernetes-backup
mv /var/lib/kubelet /var/lib/kubelet-backup

# restore certificates
mkdir -p kubernetes
cp -r kubernetes-backup/pki kubernetes
rm kubernetes/pki/{apiserver.*,etcd/peer.*}

systemctl start docker

# reinit master with data in etcd
# add –kubernetes-version, –pod-network-cidr and –token options if needed
kubeadm init –ignore-preflight-errors=DirAvailable–var-lib-etcd

# update kubectl config
cp kubernetes/admin.conf ~/.kube/config

# wait for some time and delete old node
sleep 120
kubectl get nodes –sort-by=.metadata.creationTimestamp
kubectl delete node $(kubectl get nodes -o jsonpath='{.items[?(@.status.conditions[0].status==”Unknown”)].metadata.name}’)

# check running pods
kubectl get pods –all-namespaces

 

Note

This Post was inspired by ticket 338

https://github.com/kubernetes/kubeadm/issues/338

If you have found my website, guides, articles or videos useful, please buy me a coffee