New to KubeDB? Please start here.
Etcd Storage Autoscaling
This guide gives an overview of how the KubeDB Autoscaler operator autoscales the storage of an
etcd cluster using the EtcdAutoscaler CRD.
Before You Begin
- You should be familiar with the following
KubeDBconcepts:
How Storage Autoscaling Works
The autoscaling process consists of the following steps:
A user creates an
EtcdCustom Resource (CR).The
KubeDBProvisioner operator watches theEtcdCR.When the operator finds an
EtcdCR, it creates thePetSetand the related resources. Each ordinal of the PetSet gets a PersistentVolume from the volume claim template, which is where the etcd member’s data directory (the bbolt backend and the WAL) lives.To set up storage autoscaling for that cluster, the user creates an
EtcdAutoscalerCRO with the desired configuration.The
KubeDBAutoscaler operator watches theEtcdAutoscalerCRO.The
KubeDBAutoscaler operator continuously reads the PVC usage of the database’s pods from thecustom.metrics.k8s.ioAPI backed by the KubeDB storage-metrics apiserver and compares it againstspec.storage.etcd.usageThreshold.- If the usage exceeds the threshold, the operator computes a new size and creates an
EtcdOpsRequestof typeVolumeExpansionto expand the storage.
- If the usage exceeds the threshold, the operator computes a new size and creates an
The
KubeDBOps-manager operator watches thatEtcdOpsRequestCRO.The
KubeDBOps-manager operator then expands the volumes of the etcd members as specified in theEtcdOpsRequestCRO.
Why storage autoscaling matters more for etcd
etcd is unusually sensitive to a full disk. Two properties are worth keeping in mind:
- The backend database file never shrinks on its own. Deleting keys, and even compacting the keyspace history, only marks pages as reusable inside the file — the file keeps its size until it is defragmented. See Maintenance Overview.
- When the backend grows past
--quota-backend-bytes(spec.configuration.tuning.quotaBackendBytes), etcd raises a cluster-wideNOSPACEalarm and the cluster goes read-only until the alarm is cleared.
Storage autoscaling gives the volume headroom; it does not by itself reclaim space inside the
backend file. The two are complementary — use autoscaling for the volume, and
Compact + Defragment for the backend file.
The generated EtcdOpsRequest
As with compute autoscaling, the autoscaler never edits the Etcd object directly. When the
usage threshold is crossed it creates an EtcdOpsRequest:
- Named with the
etcdops-prefix plus a random suffix, for exampleetcdops-etcd-autoscale-w7q2rk. - Owned by the
EtcdAutoscalerthrough an owner reference. - With
spec.type: VolumeExpansion,spec.volumeExpansion.etcdset to the newly computed size, andspec.volumeExpansion.modecopied fromspec.storage.etcd.expansionMode. - With
spec.timeout,spec.applyandspec.maxRetriestaken fromEtcdAutoscaler.spec.opsRequestOptions, when that block is present.
The request is only created when the newly computed size is actually larger than the current
spec.storage.resources.requests.storage of the Etcd object; storage is never scaled down.
In the next doc, we show a step-by-step guide for autoscaling the storage of an etcd cluster
using the EtcdAutoscaler CRD.
































