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

systemctl stop kubelet docker

Step 3: Backup Kubernetes data

    cd /etc/
    mv kubernetes kubernetes-backup
    mv /var/lib/kubelet /var/lib/kubelet-backup

Step 4: Create new set of kubernetes certificates.

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

Step 5: Now start the docker service

service docker start

Step 6: Now reinitialize the kubernetes cluster without losing the data on etcd.

    kubeadm init --ignore-preflight-errors=DirAvailable--var-lib-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

cp kubernetes/admin.conf ~/.kube/config

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.

kubeadm reset

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.


Prabhin Prabharkaran Administrator
DevOps Engineer

He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!

follow me
We need your support!!
Other Amount:
Questions Answered
Articles Written
Overall Points

Prabhin Prabharkaran

He is Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!!

You may also like...

Leave a Reply