New to KubeDB? Please start here.
Rotate Authentication of Etcd
This guide gives an overview of how the KubeDB Ops-manager operator rotates the credentials of an
Etcd cluster.
Before You Begin
- You should be familiar with the following
KubeDBconcepts:
How etcd authentication is stored
KubeDB creates a kubernetes.io/basic-auth shaped Secret named <db-name>-auth for every Etcd
object (unless you point spec.authSecret.name somewhere else). It carries two keys:
| Key | Description |
|---|---|
username | The etcd RBAC user. It is always root for a KubeDB provisioned cluster. |
password | That user’s password. |
These are the standard core.BasicAuthUsernameKey / core.BasicAuthPasswordKey keys, so the same
Secret can be consumed directly by an application, by etcdctl --user=<username>:<password>, and by
KubeDB’s own health checker through the generated AppBinding.
Why rotating etcd credentials does not restart anything
This is the one thing that makes etcd’s RotateAuth different from most other KubeDB databases.
An etcd RBAC user does not live in a config file or in an environment variable — it lives inside
the keyspace, managed by etcd’s own UserChangePassword / UserAdd / UserGrantRole RPCs. A
password change therefore takes effect on the next authentication, with no process restart and no
pod eviction involved. Compare that with PostgreSQL, where the credential is threaded through the
pod’s environment and the ops request has to roll every pod for the change to be picked up.
So an EtcdOpsRequest of type RotateAuth:
- writes the new password into etcd’s RBAC store,
- updates the auth Secret,
- and reaches
Successfulwithout evicting a single pod.
You will not see any EvictPod--<pod>, CheckPodReady--<pod> or RestartEtcdPods condition on an
etcd RotateAuth request, and pod AGE / RESTARTS are unchanged when it finishes.
How the rotation is staged
The rotation writes to two independent places — etcd’s own RBAC store and a Kubernetes Secret — so it is deliberately staged, in order to stay crash safe:
- The new password is parked in a
password.nextkey on the Secret, whilepasswordremains the live one. Nothing that reads the Secret is disturbed yet. - The operator applies the staged password inside etcd. If it is re-run after a crash, it first probes whether the new credential already authenticates, so the step is idempotent.
- Only once etcd has accepted the change is the staged value promoted: it becomes
password, the superseded value is kept underpassword.prev, andpassword.next/username.nextare removed. TheEtcdobject’sspec.authSecret.activeFromtimestamp is stamped at the same time.
The .prev keys are kept for rollback purposes; nothing in KubeDB reads them afterwards.
Two ways to rotate
Operator generated. Apply an
EtcdOpsRequestof typeRotateAuthwith nospec.authentication. KubeDB generates a random password, stages it and promotes it in the existing auth Secret. The Secret’s name does not change.User provided. Create your own
kubernetes.io/basic-authSecret containing the desiredusernameandpassword, and reference it fromspec.authentication.secretRef. The operator validates that both keys are present and non-empty, applies the password to etcd, records the superseded credential in your Secret underusername.prev/password.prev, and repointsspec.authSecretof theEtcdobject at your Secret withexternallyManaged: true.
How the Rotate Authentication Process Works
A user first creates an
EtcdCustom Resource Object (CRO).The
KubeDB Provisioneroperator continuously watches forEtcdCROs.When the operator detects an
EtcdCR, it provisions the requiredPetSetalong with related resources such as Secrets, Services and RBAC objects — including the<db-name>-authSecret.To initiate a credential rotation, the user creates an
EtcdOpsRequestCR of typeRotateAuth, optionally referring to their own Secret.The
KubeDB Ops-manageroperator watches forEtcdOpsRequestCRs.Upon detecting one, it pauses the referenced
Etcdobject so that the Provisioner operator does not act on it during the rotation.The operator stages the new credential on the Secret (
UpdateCredentialcondition).It then applies the credential to the cluster through etcd’s RBAC API (
EtcdCredentialAppliedcondition). If the cluster has never had etcd authentication enabled, this step bootstraps it: it creates therootuser, grants it therootrole and callsAuthEnable.The staged credential is promoted to the live one, and the
Etcdobject’sspec.authSecretreference andactiveFromtimestamp are updated (UpdateDatabasecondition).Finally the operator resumes the
Etcdobject and marks the requestSuccessful. No pod is restarted at any point.
In the next doc, we walk through both rotation flows step by step.
































