<p>I use <code>.kube/config</code> to access Kubernetes api on a server. I am wondering does the token in config file ever get expired? How to prevent it from expire?</p>

cometta
<p>Yes, it will be expired after one year.  Automatic certificate renewal feature is the default on kubernetes 1.15 version unless you have explicitly disabled it during the kubeadm init phase with  --certificate-renewal=false option.</p>

<p><strong>Check expiration:</strong></p>

<pre><code>    kubeadm alpha certs check-expiration
</code></pre>

<p>E.g.</p>

<p>CERTIFICATE                EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED</p>

<p>admin.conf                 Sep 06, 2020 04:34 UTC   361d            no<br>
apiserver                  Sep 06, 2020 04:34 UTC   361d            no<br>
apiserver-etcd-client      Sep 06, 2020 04:34 UTC   361d            no<br>
apiserver-kubelet-client   Sep 06, 2020 04:34 UTC   361d            no<br>
controller-manager.conf    Sep 06, 2020 04:34 UTC   361d            no<br>
etcd-healthcheck-client    Sep 06, 2020 04:34 UTC   361d            no<br>
etcd-peer                  Sep 06, 2020 04:34 UTC   361d            no<br>
etcd-server                Sep 06, 2020 04:34 UTC   361d            no<br>
front-proxy-client         Sep 06, 2020 04:34 UTC   361d            no<br>
scheduler.conf             Sep 06, 2020 04:34 UTC   361d            no </p>

<p><strong>Renew all certifications:</strong></p>

<pre><code>  kubeadm alpha certs renew all
</code></pre>

<p><strong>Renew only admin.conf:</strong></p>

<pre><code>  kubeadm alpha certs renew admin.conf
  cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
</code></pre>
