<p>I created a k8s installed by k0s on the aws ec2 instance. In order to make delivery new cluster faster, I try to make an AMI for it.</p>
<p>However, I started a new ec2 instance, the internal IP changed and the node become <code>NotReady</code></p>
<pre><code>ubuntu@ip-172-31-26-46:~$ k get node
NAME               STATUS     ROLES    AGE   VERSION
ip-172-31-18-145   NotReady   &lt;none&gt;   95m   v1.21.1-k0s1
ubuntu@ip-172-31-26-46:~$
</code></pre>
<p>Would it be possible to reconfigure it ?</p>
<hr />
<h2>Work around</h2>
<p>I found a work around to make the AWS AMI working</p>
<h4>Short answer</h4>
<ol>
<li>install node with kubelet's <code>--extra-args</code></li>
<li>update the kube-api to the new IP and restart the kubelet</li>
</ol>
<h2>Details :: 1</h2>
<p>In the kubernete cluster, the <code>kubelet</code> plays the node agent node. It will tell <code>kube-api</code> &quot;Hey, I am here and my name is XXX&quot;.</p>
<p>The name of a node is its hostname and could not be changed after created. It could be set by <code>--hostname-override</code>.</p>
<p>If you don't change the node name, the <code>kube-api</code> will try to use the hostname then got errors caused by <code>old-node-name</code> not found.</p>
<h2>Details :: 2</h2>
<p>To k0s, it put kubelet' KUBECONFIG in the <code>/var/lib/k0s/kubelet.conf</code>, there was a kubelet api server location</p>
<pre><code>server: https://172.31.18.9:6443
</code></pre>
<p>In order to connect a new kube-api location, please update it</p>

qrtt1
<p>Did you check the kubelet logs? Most likely it's a problem with certificates. You cannot just make an existing node into ami and hope it will work since certificates are signed for specific IP.</p>
<p>Check out the <a href="https://github.com/awslabs/amazon-eks-ami" rel="nofollow noreferrer">awslabs/amazon-eks-ami</a> repo on github. You can check out how aws does its k8s ami.</p>
<p>There is a <a href="https://github.com/awslabs/amazon-eks-ami/blob/5a3df0fdb17e540f8d5a9b405096f32d6b9b0a3f/files/bootstrap.sh" rel="nofollow noreferrer">files/bootstrap.sh</a> file in repo that is run to bootstrap an instance. It does all sort of things that are instance specific which includes getting certificates.</p>
<p>If you want to <em>&quot;make delivery new cluster faster&quot;</em>, I'd recommend to create an ami with <a href="https://docs.k0sproject.io/v1.21.1+k0s.0/k0s-multi-node/#1-download-k0s" rel="nofollow noreferrer">all dependencies</a> but without an actual k8s boostraping. Install the k8s (or k0s in your case) after you start the instance from ami, not before. (Or figure out how to regenerate certs and configs that are node specific.)</p>
