Allow configuring vtbackup storage separately from tablet pools (#661) - #798
Open
mcrauwel wants to merge 9 commits into
Open
Allow configuring vtbackup storage separately from tablet pools (#661)#798mcrauwel wants to merge 9 commits into
mcrauwel wants to merge 9 commits into
Conversation
vtbackup Pods (the initial backup taken at shard creation and any
periodic/scheduled backups) inherit their spec from the tablet pool,
including DataVolumeClaimTemplate. That forces a PVC and disk allocation
per shard just to bootstrap an empty backup, which is wasteful and
sometimes unschedulable in large clusters.
Add an optional `vtbackup` block on VitessShardTabletPool with a
`dataVolumeClaimTemplate` override:
- block omitted -> inherit the pool's data volume (unchanged).
- block present, empty -> vtbackup Pods run with no PVC (ephemeral
emptyDir scratch space).
- template set -> vtbackup Pods use that template (e.g. a
smaller disk or a different storageClass).
Both vtbackup code paths funnel through MakeVtbackupSpec, so the override
applies consistently to initial and scheduled backups. Tablet Pods are
unaffected.
Tests: unit coverage of all three states, plus an integration assertion
that an empty override yields a vtbackup-init Pod with no PVC-backed
volume while the tablets keep their PVCs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Matthias Crauwels <matthias.crauwels@planetscale.com>
…a-volume-override
Signed-off-by: Matt Lord <mattalord@gmail.com>
frouioui
reviewed
Jul 21, 2026
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
frouioui
approved these changes
Aug 3, 2026
…a-volume-override # Conflicts: # test/endtoend/operator/operator-latest.yaml # test/integration/vitesscluster/vitesscluster_test.go
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
mattlord
approved these changes
Aug 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #661.
This change adds an optional
vtbackupblock alongsidetabletPoolsinVitessShardTemplate. It allows vtbackup Pods to use scratch storage that differs from the tablet-pool storage they otherwise inherit.Historically, vtbackup Pods inherited the first tablet pool's
dataVolumeClaimTemplate. That behavior allocates a PVC and an underlying disk per shard, even for the initial backup of an empty database. Large clusters can therefore allocate substantial unused storage or fail to bootstrap when those PVCs cannot bind.Configuration
Set
useEmptyDirForInitialBackupto let the initial backup use ephemeral scratch space while tablet Pods retain their normal PVCs:A shard template can instead provide a dedicated PVC template for vtbackup Pods:
useEmptyDirForInitialBackup: trueanddataVolumeClaimTemplateare mutually exclusive. The CRD rejects configurations that set both.Semantics
vtbackupconfigurationuseEmptyDirForInitialBackup: trueemptyDirscratch spacedataVolumeClaimTemplatesetScheduled backups retain persistent scratch storage when
useEmptyDirForInitialBackupis set because vtbackup restores the latest full database before taking a new backup. Using an unboundedemptyDirfor that workload could cause node disk pressure or eviction.Omitting the block, supplying an empty block, or explicitly setting
useEmptyDirForInitialBackup: falsepreserves the historical behavior. Tablet Pod storage is unaffected.Storage reconciliation
The operator records a hash of the desired vtbackup PVC template on the initial-backup Pod and PVC. It separately records a hash of the Pod's effective
/vt/vtdatarootmount and referenced volume source on the Pod. This accounts forextraVolumesandextraVolumeMountsthat override the default data mount without changing the PVC template.When the storage configuration changes, the operator:
For upgrades, the controller adopts hashless resources and resources created by the earlier single-hash implementation when their effective Pod and PVC configuration already matches the desired configuration. The comparison accounts for Kubernetes-assigned defaults and bindings without conflating an explicit empty storage class or a user-prebound volume with controller-assigned values. If the controller cannot read a legacy PVC, it preserves the Pod and retries instead of making a destructive decision from incomplete state.
This allows the controller to converge across PVC-to-
emptyDir,emptyDir-to-PVC, custom-PVC-template, and effective Pod-volume changes. In particular, settinguseEmptyDirForInitialBackup: truecan recover an initial backup that is Pending because its inherited PVC cannot bind.Scope
This change only separates vtbackup data-volume configuration from tablet-pool storage. Broader vtbackup Pod overrides can build on the dedicated
vtbackupblock in follow-up work.Tests
emptyDir, and custom templates on initial and scheduled backups.useEmptyDirForInitialBackupapplies only to the initial backup.emptyDir,emptyDir-to-PVC, custom-template, and effective Pod-volume transitions.useEmptyDirForInitialBackup: trueremoves the initial-backup PVC while tablet Pods retain theirs.Local verification:
go test -count=1 ./pkg/...go test -race -count=1 ./pkg/controller/vitessshard ./pkg/controller/vitessbackupschedule ./pkg/operator/vttabletgolangci-lint: 0 issuesgit diff --check