Skip to main content

What is the safe procedure for rotating Hetzner credentials?

Syself support For release

To rotate the Hetzner API token for Kubernetes clusters on Syself Autopilot, create the new token first, then update the hetzner Secret in the management cluster. Revoke the old token only after your clusters use the new one, so they never run without a valid token.

For the Hetzner Cloud API token:

  1. Create a new API token with read and write permissions in the same Hetzner Cloud project.

  2. On the management cluster, set the new token as the hcloud key of the hetzner Secret in your namespace:

    plaintext
    				kubectl patch secret hetzner --type merge -p '{"stringData":{"hcloud":"<new-token>"}}'
    			
  3. Syself Autopilot copies the Secret into the kube-system namespace of each workload cluster that uses it. On each of these clusters, check that the new token arrived. This prints the last characters of the token, which is enough to compare:

    plaintext
    				kubectl -n kube-system get secret hetzner -o jsonpath='{.data.hcloud}' | base64 -d | tail -c 8
    			
  4. On each workload cluster, restart the Hetzner Cloud storage driver (CSI), so it reads the new token. The cloud controller manager picks up the new token on its own.

    plaintext
    				kubectl -n kube-system rollout restart deployment csi-controller
    			
  5. Revoke the old token in the Hetzner Cloud Console.

For the Hetzner Robot webservice user, there is no overlap. The old password stops working as soon as you change it in Hetzner Robot. Change it, then update the robot-user and robot-password keys of the same Secret right away, so bare-metal provisioning is not held up:

plaintext
				kubectl patch secret hetzner --type merge -p '{"stringData":{"robot-user":"<user>","robot-password":"<new-password>"}}'
			

The token and the Secret come from the setup in Connect your Hetzner account. If you are not sure which clusters share a Secret, see Can each cluster use its own Hetzner project or secret?

Still stuck?

Prepare your case, then email us.