I have been troubled by the title recently cause I have my cluster deployed on the cloud and in order to down cost, I shut down VMs while not using them.
Since the public ip address of the VM changes once stop and start again, my kube-apiserver ip address becomes inconsistence with the new public ip address. And it cause me unable to access the cluster, while the cluster is actually running and working fine.
I know I can solve this problem by as simeple as assigning an elastic ip address to the server, but on the other hand, I am also very curious about how to change the kube-apiserver ip address if needed.
So my goal is to just update the kube-apiserver with new ip address without affecting any running loading in the cluster. I found this post totally answered my curiosity and this post is a walk through of the content.
Currently, my VM’s public ip address is 18.x.x.16, yet my kube-apiserver’s public ip address is 18.x.x.185.
Therefore when I issued kubectl commands, it is looking for the old .185 ip yet my server’s ip has changed to .16.
Let’s start by stop the services and back up the current data.
Next, we keep the certificates we need.
Now we can reinit control plane node with data in etcd using command below. Flag appended at the end is the key point to tell kubeadm to use the pre-existing etcd data.
kubeadm init --control-plane-endpoint 18.x.x.16 \
Once done, you will see the familiar page as below.
We could also verify that kube-apiserver ip is indeed changed to the current ip address 18.x.x.16.
And Yes! We could still see the previous running loadings!
All commands are here, you can curl the url to execute all commands.
That’s it for this post, hope you like it and find it useful : )