Day 2
Rotate cluster credentials
Keep the published kubeconfig and talosconfig short-lived. Change a CA of a cluster when it is necessary.
What the operator does and does not do
Section titled “What the operator does and does not do”| Item | The operator |
|---|---|
Admin kubeconfig <cluster>-kubeconfig |
Issues it again when less than one third of its TTL is left |
Admin talosconfig <cluster>-talosconfig |
The same |
Reader talosconfig <cluster>-talosconfig-reader |
Publishes it when readerTalosconfig: true |
| Talos, Kubernetes and etcd CAs | Does not rotate them. You do it with talosctl. |
Set the credential lifetime
Section titled “Set the credential lifetime”-
Set
spec.credentialson the TalosCluster.spec:credentials:ttl: 8hreaderTalosconfig: true -
Apply it.
Terminal window kubectl apply -f cluster.yamlThe operator replaces a credential with a longer TTL at once.
-
Read when the first published credential expires.
Terminal window kubectl get taloscluster prod -o jsonpath='{.status.credentialsExpireAt}'
A tool that copies a credential out of the cluster must copy it again before that time.
Rotate a CA
Section titled “Rotate a CA”talosctl rotate-ca changes the machine configs directly. The operator still renders with the old bundle. Its dry run then shows drift, and a Config rollout would put the old CA back. While the operator holds the bundle (SecretsBundleHeld=True), the operator proposes and plans no rollout that applies a config. Between step 1 and step 4 there is no hold yet.
-
Rotate the CA on each node of the cluster with
talosctl, as the Talos documentation says. The operator continues with the old bundle. -
Read the machine config of one control plane after the rotation.
Terminal window talosctl -n <control-plane> read /system/state/config.yaml > cp.yaml -
Make the new bundle from it.
Terminal window talosctl gen secrets --from-controlplane-config cp.yaml -o secrets.yaml -
When each machine trusts the new bundle, put it into the Secret that
spec.secretsRefnames. The key must besecrets.yaml.Terminal window kubectl -n pk-metal create secret generic prod-talos-secrets --from-file=secrets.yaml \--dry-run=client -o yaml | kubectl apply -f - -
Delete the two files. They hold the keys of the cluster.
Terminal window shred -u cp.yaml secrets.yaml -
Make sure that the cluster shows
SecretsBundleHeld=True. The operator still uses its copy.Terminal window kubectl describe taloscluster prod -
Delete the copy of the old bundle.
Terminal window kubectl -n pk-metal delete secret prod-bundle-appliedThe operator takes the bundle from the spec and makes a new copy.
Verify
Section titled “Verify”SecretsBundleHeld=False.kubectl --kubeconfig prod.kubeconfig get nodesworks with a fresh copy of the kubeconfig.
If it fails
Section titled “If it fails”If you changed the bundle Secret by mistake, put the old bundle back. SecretsBundleHeld returns to False.
Related
Section titled “Related”- TalosCluster, TalosCluster controller
- Rotate BMC credentials
- Monitor the fleet has the alert for credentials that do not renew.