<p>I have created a kubernetes cluster where I have a master node and two worker nodes. I initialised master node using below command </p>

<pre><code>sudo kubeadm init --token-ttl=0 --apiserver-advertise-address=192.168.0.27
</code></pre>

<p><code>192.168.0.27</code> is the ip address of master node. Then I used the generated token to start my worker nodes. Now the problem is that my network is in DHCP and the ip address changes sometime due to which it starts showing below error:</p>

<pre><code>Unable to connect to the server: dial tcp 192.168.0.27:6443: getsockopt: no route to host
</code></pre>

<p>It shows above error because at the time of initializing the master node, I have  used the ip address and after the ip address changes, its not able to access it.</p>

<p>Is it possible to configure master and other nodes in some way so that they can work regardless of any ip address change.</p>

<p>Thanks</p>

<p>As @Suresh Vishnoi mentioned, it is not possible to set a DNS name in current stable versions of Kubernetes because of <a href="https://github.com/kubernetes/kubernetes/blob/d7cadf5d180277cfed7fd57d1e1a125c538bd751/cmd/kubeadm/app/util/endpoint.go#L41" rel="nofollow noreferrer">implementation</a>. </p>

<p>But, merge request with that feature - new key for DNS name instead of IP address are already <a href="https://github.com/kubernetes/kubernetes/commit/d7cadf5d180277cfed7fd57d1e1a125c538bd751" rel="nofollow noreferrer">merged</a> into Kubernetes master and available from version <code>v1.10.0-beta.4</code>.</p>

<p>In your case, it is not possible to use DNS name for discovery, but, you can set up your DHCP server for associate IP address from DHCP pool to MAC address of your master, which will able you to using all features of DHCP, but an address of your master will be always same. </p>

<p>Standard Linux <code>dhcpd</code> DHCP server you can configure like that (replace a mac address and IP to which one you need):</p>

<p><code>host KubeMaster {
  hardware ethernet 00:1F:6A:21:71:3F;
  fixed-address 10.0.0.101;
}</code></p>

<p>If you using any router or different OS for your DHCP server, then please check their documentation.</p>
