New to KubeDB? Please start here.
Reconfiguring TLS of Etcd
This guide gives an overview of how the KubeDB Ops-manager operator reconfigures the TLS configuration of an Etcd cluster — adding TLS, removing TLS, changing the Issuer/ClusterIssuer or certificate specs, and rotating the certificates.
Before You Begin
- You should be familiar with the following
KubeDBconcepts:
The three mutually exclusive operations
spec.tls on an EtcdOpsRequest of type ReconfigureTLS describes exactly one operation per request. The admission webhook counts them and rejects a request that names more than one, with only one TLS reconfiguration operation is allowed at a time:
| Operation | Field(s) | Meaning |
|---|---|---|
| Remove TLS | remove: true | Clears spec.tls on the Etcd object, re-renders the members without any TLS flags, and deletes the now-orphaned Certificate objects. |
| Rotate | rotateCertificates: true | Asks cert-manager to re-issue every existing certificate, keeping the same issuer and the same certificate specs. |
| Issue / update | issuerRef and/or certificates | Points the cluster at a different Issuer/ClusterIssuer, or changes the per-alias certificate specs. This is also how you add TLS to a cluster that does not have it yet. |
Two further validations are worth knowing before you write the request:
rotateCertificates: truerequires TLS to be enabled already — the webhook rejects it withrotateCertificates requires TLS to already be enabled with issuerRef on Etcd. There is nothing to rotate otherwise.- When you supply only
certificates(noissuerRef), theEtcdobject must already carry anissuerRef, otherwise the request is rejected withtls.issuerRef is required for Etcd ReconfigureTLS.
How the reconfiguring process works
A user creates an
EtcdCustom Resource Object (CRO).The
KubeDBProvisioner operator watches theEtcdCRO and creates thePetSetand the necessary secrets, services, etc.In order to change the TLS configuration, the user creates an
EtcdOpsRequestCR of typeReconfigureTLS.The
KubeDBOps-manager operator watches theEtcdOpsRequestCR.When it finds one, it pauses the referenced
Etcdobject, so the Provisioner operator does not fight it for ownership of thePetSetduring the operation.The operator folds the request into a copy of the
Etcdobject and reconciles the cert-managerCertificateobjects from it — creating, updating or (forremove) preparing to delete them. For a rotation it puts cert-manager’sIssuingcondition on eachCertificate, which is what makes cert-manager re-issue it.It then waits for cert-manager to finish, recording the
CertificateSyncedcondition on the ops request once every certificate secret carries the new material.It re-renders the
PetSet(conditionUpdateEtcdPetSet). The TLS flags, volumes and volume mounts on the etcd container are all derived fromspec.tls, so this single step covers adding, changing and removing TLS.It restarts the members (condition
RestartEtcdPods). This is the leader-aware rolling restart: the operator identifies the current Raft leader, restarts every follower first — one at a time, waiting for each pod to become Ready and for the cluster to report quorum before moving to the next — and restarts the leader last, after handing its leadership to another voter with etcd’sMoveLeaderRPC. The ordering matters for etcd in a way it does not for a leader/follower SQL database: evicting the leader outright triggers an election, and an election makes the cluster unavailable for writes for an election timeout, whereas a deliberate transfer is near instantaneous. Peer traffic is mutually authenticated, so a member restarted with new material also has to rejoin the quorum before the next one is taken down.It writes the new
spec.tlsback onto theEtcdobject (conditionUpdateDatabase) and deletes anyCertificateobjects that are no longer referenced.Finally it resumes the
Etcdobject so the Provisioner operator returns to its usual duties, and marks the ops requestSuccessful.
Because step 9 restarts every member one at a time and waits for quorum in between, the cluster stays available for reads and writes throughout — a ReconfigureTLS is not a downtime operation for a 3-member (or larger) cluster. A single-member cluster (replicas: 1) has no quorum to preserve and will be briefly unavailable while its only member restarts.
In the next doc, we show a step-by-step guide for each of the four scenarios using the EtcdOpsRequest CRD.
































