New to KubeDB? Please start here.
Etcd Volume Expansion
This guide gives an overview of how the KubeDB Ops-manager operator expands the data volumes of an
Etcd cluster.
Before You Begin
- You should be familiar with the following
KubeDBconcepts:
How Volume Expansion Process Works
Each etcd member owns one PVC, provisioned from the PetSet’s volume claim template and named
data-<db-name>-<ordinal> (for example data-etcd-cluster-0). It holds etcd’s data directory
(/var/lib/etcd) — the WAL and the backend database file.
The volume expansion process consists of the following steps:
At first, a user creates an
EtcdCustom Resource (CR).The
KubeDBProvisioner operator watches theEtcdCR and creates thePetSet, whose volume claim template provisions one PVC per member.In order to expand those volumes, the user creates an
EtcdOpsRequestCR of typeVolumeExpansionwith the desired size and a mode.The
KubeDBOps-manager operator watches theEtcdOpsRequestCR.When it finds one, it pauses the referenced
Etcdobject, so the Provisioner operator does not reconcile it during the expansion, and records the current member count on the ops request (it has to be restored later — see step 8).It then expands the volumes in the requested mode (
OnlineorOffline, see below): each member’s PVC is patched with the new storage request, and the operator waits until the PVC’sstatus.capacityactually reflects the new size — the CSI driver, not KubeDB, does the growing.Once every PVC has grown, the operator deletes the
PetSetwith an orphan propagation policy. This step is unavoidable:spec.volumeClaimTemplatesis immutable, so thePetSethas to be recreated to carry the new size. Orphaning means the member pods are not deleted along with it — which is what keeps anOnlineexpansion non-disruptive.The operator persists the new size onto
spec.storage.resources.requests.storageof theEtcdobject and re-renders thePetSetfrom it. A freshly createdPetSetis seeded with a single replica (the bootstrap seed), so the operator immediately restores the member count it recorded in step 5, while the database is still paused — this keeps thePetSetcontroller from deleting the higher-ordinal pods in between.Finally, the operator resumes the
Etcdobject and marks theEtcdOpsRequestSuccessful.
Volume Expansion Modes
spec.volumeExpansion.mode is required and selects how the members are treated while their
volumes grow:
Online— the member pods keep running throughout. The operator patches every PVC and lets the CSI driver grow the filesystem underneath the live pods. Because thePetSetis deleted with orphaned pods and recreated afterwards, etcd never stops serving and quorum is never affected. This requires aStorageClasswithallowVolumeExpansion: trueand a CSI driver that supports online (mounted) filesystem expansion.Offline— the operator first scales thePetSetto0and waits for every member pod to terminate, then patches the PVCs, then recreates everything. Use this when the CSI driver requires the volume to be unmounted before it can be resized. The cluster is fully unavailable for the duration. This is safe for etcd — the Raft log and the snapshot live on the very volumes being expanded, so a full cluster stop loses nothing, it just loses availability.
Note that in both modes the PVCs are patched for all members together, not one member at a time.
Online is therefore not a rolling operation with a per-member quorum gate; it is a single
non-disruptive resize of every volume.
Preconditions
spec.storageTypemust beDurable. There is nothing to expand on anEphemeraletcd, and the ops request fails outright.- The
StorageClassbacking the volumes must haveallowVolumeExpansion: true. - Volumes can only grow. The validating webhook rejects a
spec.volumeExpansion.etcdvalue that is smaller than the current request.
Sizing tip. etcd’s disk usage is bounded by its backend quota (
spec.configuration.tuning.quotaBackendBytes), not by how much data you write over time — but the on-disk file only shrinks after aCompactfollowed by aDefragment. If you are expanding because the backend file grew, consider whether compaction/defragmentation is the actual fix before buying more disk.
In the next doc, we are going to show a
step-by-step guide on expanding the volumes of an Etcd cluster using the EtcdOpsRequest CRD.
































