New to KubeDB? Please start here.
Reconfiguring Etcd
This guide gives an overview of how the KubeDB Ops-manager operator reconfigures a running Etcd
cluster.
Before You Begin
- You should be familiar with the following
KubeDBconcepts:
What “configuration” means for Etcd
Most KubeDB databases are configured through a config file that is mounted into the pod — a
configSecret whose contents are merged with the operator’s defaults. Etcd is different.
etcd’s --config-file is mutually exclusive with individual command line flags: if you hand etcd
a config file, that file has to own every single setting, including the bootstrap flags KubeDB
computes per member (--name, --initial-advertise-peer-urls, --listen-peer-urls,
--listen-client-urls, --advertise-client-urls, the TLS file paths, and so on). Silently taking
over those would break membership management.
So KubeDB exposes a small, typed set of tuning knobs instead, under spec.configuration.tuning,
and renders them straight onto the etcd command line:
| Field | etcd flag | Type | Meaning |
|---|---|---|---|
quotaBackendBytes | --quota-backend-bytes | int64 | Maximum size of the backend database. etcd raises a NOSPACE alarm and goes read-only once the backend grows past it. |
autoCompactionMode | --auto-compaction-mode | string | Either periodic or revision; selects how autoCompactionRetention is interpreted. |
autoCompactionRetention | --auto-compaction-retention | string | A duration (e.g. 1h) when the mode is periodic, a revision count (e.g. 1000) when the mode is revision. |
snapshotCount | --snapshot-count | uint64 | Number of committed transactions that trigger a snapshot to disk. |
Two consequences follow from this design, and they are the two things worth remembering about reconfiguring etcd:
spec.configuration.applyConfigis not supported.applyConfigmerges free-form key/value pairs into a rendered config file, and there is no such file here — accepting it would silently drop your settings. AnEtcdOpsRequestthat sets it is rejected at admission, telling you to usespec.configuration.tuninginstead. (spec.configuration.configSecretis accepted by the schema but never mounted, so it has no effect either.)- A
Reconfigureneeds a restart to take effect. The knobs are process command line flags, and etcd has no live-reload path for them (there is no equivalent of PostgreSQL’spg_reload_conf()). The new values only take effect when the member process is started again, so the ops request ends with a leader-aware rolling restart by default. Settingspec.configuration.restart: "false"skips that restart — theEtcdobject and thePetSetare updated, but the running members keep their old values until something else restarts them.
How the Reconfiguring Etcd Process Works
The reconfiguration process consists of the following steps:
At first, a user creates an
EtcdCustom Resource (CR).The
KubeDBProvisioner operator watches theEtcdCR.When the operator finds an
EtcdCR, it creates the requiredPetSetand the related resources like Secrets, Services, and so on.Then, in order to reconfigure the cluster, the user creates an
EtcdOpsRequestCR of typeReconfigure, carrying the desiredspec.configuration.tuningvalues.The
KubeDBOps-manager operator watches theEtcdOpsRequestCR.When it finds an
EtcdOpsRequestCR, it pauses theEtcdobject referred to by the request, so that the Provisioner operator does not perform any operation on it during reconfiguration.The Ops-manager operator folds the requested knobs into the
Etcdobject’sspec.configuration.tuning. Only the knobs the request actually names are touched, so a partial reconfigure never silently resets the others.It then re-renders the
PetSetfrom the patched spec, so the etcd container args carry the new flags. This is tracked by theUpdateEtcdPetSetcondition.Finally it rolls the member pods so that they come up with the new flags. This reuses exactly the same leader-aware sequence as the Restart ops request: followers first, one at a time, quorum verified between each, and the Raft leader last, after its leadership has been transferred away.
After the members have restarted successfully, the Ops-manager operator resumes the
Etcdobject so that the Provisioner operator resumes its usual operations.
Setting the tuning knobs at creation time — that is, on the
Etcdobject itself rather than through an ops request — is covered by the Custom Configuration guide and byspec.configurationin the Etcd concept doc. This guide is only about changing them on an already running cluster with anEtcdOpsRequest.
In the next doc, we are going to show a step by step
guide on reconfiguring an Etcd cluster using the EtcdOpsRequest CRD.
































