How to change Kubernetes master and worker node IP address2 min read
In this tutorial, we explain what steps need to be taken during changing the IP address of the Kubernetes master and worker node.
This kind of situation comes up when you are reorganizing your network. The below steps help you to reconfigure the Kubernetes cluster without losing any data.
Before performing the changes its always recommended to perform a backup, backup can be an instance snapshot or checkpoint.
Step 1: Configure the new IP address for your instance, Now perform the change for the master server.
Step 2: Stop kubelet and docker service
Step 3: Backup Kubernetes data
Step 4: Create new set of kubernetes certificates.
Step 5: Now start the docker service
Step 6: Now reinitialize the kubernetes cluster without losing the data on etcd.
append any flags if you used before like –pod-network-cidr
above command generate the new Kubernetes configuration file, certificates based on the new IP address which is allocated to the machine. This will not wipe out the etcd data. so all you cluster secret, deployment all the data remains in the cluster itself.
Step 7: Now update the Kube configuration
This replaces your old kube-config, with a new certificate and API server details.
Step 8: Now is the time to reset the worker nodes. Update the IP address in the worker nodes.
Step 9: Once the new IP address is allocated to the worker node. execute reset command in worker node.
Step 10: Now rejoin the worker to kubernete cluster.
Get the join token from the master by executing below command,
kubeadm token create --print-join-command
Executing the output join command in the worker command.
After this, you are done with all the changes required for changing the IP address.
Now you will be able to perform all the cluster operations and all your old data in place.