How can i rotate admin.conf in kubernetes?

5/5/2021

I need to rotate admin.conf for a cluster so old users who used that as their kubeconfig wouldn't be allowed to perform actions anymore. How can i do that?

-- Julessoulfly
devops
kubernetes

1 Answer

5/6/2021

This is a Community Wiki answer, posted for better visibility, so feel free to edit it and add any additional details you consider important.

As mdaniel wrote in his comment:

the answer to your question is "rekey the entire apiserver CA hierarchy" or wait for admin.conf cert to expire, because those admin.conf credentials are absolute. Next time, use the provided oidc mechanism for user auth.

For kubeadm based kubernetes cluster please also refer to Certificate Management with kubeadm. For manual rotation of CA Certificates, please refer to this section. Pay special attention to point 7:

  1. Update certificates for user accounts by replacing the content of client-certificate-data and client-key-data respectively.

For information about creating certificates for individual user accounts, see Configure certificates for user accounts.

Additionally, update the certificate-authority-data section in the kubeconfig files, respectively with Base64-encoded old and new certificate authority data

-- mario
Source: StackOverflow