- you suspect that the private key has been compromised;
- you want to revoke access to the cluster for a leaked
talosconfigorkubeconfig; - once in 10 years.
Overview
There are some details which make Talos and Kubernetes API root CA rotation a bit different, but the general flow is the same:- generate new CA certificate and key;
- add new CA certificate as ‘accepted’, so new certificates will be accepted as valid;
- swap issuing CA to the new one, old CA as accepted;
- refresh all certificates in the cluster;
- remove old CA from ‘accepted’.
Talos API
Automated Talos API CA Rotation
Talos API CA rotation doesn’t interrupt connections within the cluster, and it doesn’t require a reboot of the nodes. Run the following command in dry-run mode to see the steps which will be taken:talosctl command, as it will contain the new CA certificate and key.
Record a list of Talos API users to make sure they can all be updated with new talosconfig.
Run the following command to rotate the Talos API CA:
Once the rotation is done, stash the new Talos CA, update secrets.yaml (if using that for machine configuration generation) with new CA key and certificate.
The new client talosconfig is written to the current directory as talosconfig.
You can merge it to the default location with talosctl config merge ./talosconfig.
If other client access talosconfig files needs to be generated, use talosctl config new with new talosconfig.
Note: if using Talos API access from Kubernetes feature, pods might need to be restarted manually to pick up new talosconfig.
Manual Steps for Talos API CA Rotation
- Generate new Talos CA (e.g. use
talosctl gen secretsand use Talos CA). - Patch machine configuration on all nodes updating
.machine.acceptedCAswith new CA certificate. - Generate
talosconfigwith client certificate generated with new CA, but still using old CA as server CA, verify connectivity, Talos should accept new client certificate. - Patch machine configuration on all nodes updating
.machine.cawith new CA certificate and key, and keeping old CA certificate in.machine.acceptedCAs(on worker nodes.machine.cadoesn’t have the key). - Generate
talosconfigwith both client certificate and server CA using new CA PKI, verify connectivity. - Remove old CA certificate from
.machine.acceptedCAson all nodes. - Verify connectivity.
Kubernetes API
Automated Kubernetes API CA Rotation
The automated process only rotates Kubernetes API CA, used by thekube-apiserver, kubelet, etc.
Other Kubernetes secrets might need to be rotated manually as required.
Kubernetes pods might need to be restarted to handle changes, and communication within the cluster might be disrupted during the rotation process.
Run the following command in dry-run mode to see the steps which will be taken:
talosctl command, as it will contain the new CA certificate and key.
As Talos API access will not be disrupted, the changes can be reverted back if needed by reverting machine configuration.
Run the following command to rotate the Kubernetes API CA:
kubelet will re-join the cluster with new client certficiate.
New kubeconfig can be fetched with talosctl kubeconfig command from the cluster.
Kubernetes pods might need to be restarted manually to pick up changes to the Kubernetes API CA.
Manual Steps for Kubernetes API CA Rotation
Steps are similar to the Talos API CA rotation, but use:.cluster.acceptedCAsin place of.machine.acceptedCAs;.cluster.cain place of.machine.ca;kubeconfigin place oftalosconfig.