> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Actions to Take When Server IP Address Changes

> You can make necessary configuration changes for Kubernetes Master and MongoDB when server IP address changes, renew certificates, and ensure services work properly.

## Actions for Kubernetes Master:

```bash theme={null}
#IPs are changed in the following files
/etc/kubernetes/admin.conf
/etc/kubernetes/controller-manager.conf
/etc/kubernetes/kubelet.conf
/etc/kubernetes/scheduler.conf
/etc/kubernetes/manifests/etcd.yaml
/etc/kubernetes/manifests/kube-apiserver.yaml

#Existing certificates are deleted
cd /etc/kubernetes/pki
rm -rf apiserver.* apiserver-kubelet-client.*

#New certificates are created (this stage may give errors but they can be ignored)
sudo kubeadm init phase certs apiserver-kubelet-client
sudo kubeadm init phase certs apiserver
sudo systemctl restart kubelet

#Current config file is moved under user for current user's access
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
```

## Actions for MongoDB:

```bash theme={null}
#Connect to MongoDB
mongosh mongodb://<YOUR_NEW_MONGO_IP_ADDRESS>:25080 --authenticationDatabase "admin" -u "apinizer" -p

#New ip settings are given with "force" option
cfg = rs.conf()
cfg.members[0].host = "<YOUR_NEW_MONGO_IP_ADDRESS>:25080"
rs.reconfig(cfg, {force:true})
```
