<ul>
<li>Running under Ubuntu I used <code>kubeadm init</code> to setup my cluster (master node) and copied over the <code>/etc/kubernetes/admin.conf $HOME/.kube/config</code> and all was well when using <code>kubectl</code>.</li>
<li>However after a reboot my master node has had an IP address change which is not the same as what is in <code>$HOME/.kube/config</code> so now I can no longer connect <code>kubectl</code></li>
</ul>

<p>So how do I regenerate the admin.conf now that I have a new IP address? Running <code>kubeadm init</code> will just kill everything which is not what I want.</p>

TheEdge
<p>I found this solution on the internet and it works for me:</p>

<pre><code>    systemctl stop kubelet docker
    cd /etc/
    mv kubernetes kubernetes-backup
    mv /var/lib/kubelet /var/lib/kubelet-backup
    mkdir -p kubernetes
    cp -r kubernetes-backup/pki kubernetes
    rm kubernetes/pki/{apiserver.*,etcd/peer.*}
    systemctl start docker
    kubeadm init --ignore-preflight-errors=DirAvailable--var-lib-etcd
    #Run "kubeadm reset" on all nodes if was this error "error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
        [ERROR Port-10250]: Port 10250 is in use
        [ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists"
    cp kubernetes/admin.conf ~/.kube/config
    kubectl get nodes --sort-by=.metadata.creationTimestamp
    kubectl delete node $(kubectl get nodes -o jsonpath='{.items[(@.status.conditions[0].status=="Unknown")].metadata.name}')
    kubectl get pods --all-namespaces
</code></pre>

<p>After These, Join your Slaves to Master.
Reference: <a href="https://medium.com/@juniarto.samsudin/ip-address-changes-in-kubernetes-master-node-11527b867e88" rel="noreferrer">https://medium.com/@juniarto.samsudin/ip-address-changes-in-kubernetes-master-node-11527b867e88</a></p>
