<p>I am using test kubenetes cluster (Kubeadm 1 master and 2 nodes setup), My public ip change time to time and when my public IP changed, I am unable to connect to cluster and i get below error</p>
<pre><code> Kubernetes Unable to connect to the server: dial tcp x.x.x.x:6443: i/o timeout
</code></pre>
<p>I also have private IP 10.10.10.10 which is consistent all the time.</p>
<p>I have created kubernetes cluster using below command</p>
<pre><code> kubeadm init --control-plane-endpoint 10.10.10.10
</code></pre>
<p>But still it failed because certificates are signed to public IP and below is the error</p>
<pre><code> The connection to the server x.x.x.x:6443 was refused - did you specify the right host or port?
</code></pre>
<p>Can someone help to setup kubeadm, and should allow for all IP's something like 0.0.0.0 and I am fine for security view point since it is test setup. or any parament fix.</p>

<p>Since <strong>@Vidya</strong> has already solved this issue by using a static IP address, I decided to provide a Community Wiki answer just for better visibility to other community members.</p>
<p>First of all, it is not recommended to have a frequently changing  master/server IP address.<br />
As we can find in the discussion on GitHub <a href="https://github.com/kubernetes/kubernetes/issues/88648" rel="nofollow noreferrer">kubernetes/88648</a> - <code>kubeadm</code> does not provide an easy way to deal with this.</p>
<p>However, there are a few workarounds that can help us, when the IP address on the Kubernetes master node changes.
Based on the discussion <a href="https://github.com/kubernetes/kubeadm/issues/338" rel="nofollow noreferrer">Changing master IP address</a>, I prepared a script that regenerates certificates and re-init master node.</p>
<p>This script might be helpful, but I recommend running one command at a time (it will be safer).<br />
In addition, you may need to customize some steps to your needs:<br />
<strong>NOTE:</strong> In the example below, I'm using Docker as the container runtime.</p>
<pre><code>root@kmaster:~# cat reinit_master.sh 
#!/bin/bash
set -e

echo &quot;Stopping kubelet and docker&quot;
systemctl stop kubelet docker

echo &quot;Making backup kubernetes data&quot;
mv /etc/kubernetes /etc/kubernetes-backup
mv /var/lib/kubelet /var/lib/kubelet-backup

echo &quot;Restoring certificates&quot;
mkdir /etc/kubernetes
cp -r /etc/kubernetes-backup/pki /etc/kubernetes/
rm /etc/kubernetes/pki/{apiserver.*,etcd/peer.*}

echo &quot;Starting docker&quot;
systemctl start docker 


echo &quot;Reinitializing master node&quot;
kubeadm init --ignore-preflight-errors=DirAvailable--var-lib-etcd

echo &quot;Updating kubeconfig file&quot;
cp /etc/kubernetes/admin.conf ~/.kube/config
</code></pre>
<p>Then you need to rejoin the worker nodes to the cluster.</p>
