Skip to content

vmcluster/statefulset: run rolling upgrades in batches of multiple pods#1458

Merged
f41gh7 merged 2 commits intoVictoriaMetrics:masterfrom
vpedosyuk:feature/max-unavailable
Jul 8, 2025
Merged

vmcluster/statefulset: run rolling upgrades in batches of multiple pods#1458
f41gh7 merged 2 commits intoVictoriaMetrics:masterfrom
vpedosyuk:feature/max-unavailable

Conversation

@vpedosyuk
Copy link
Contributor

Fixes: #1457

This PR introduces a new VMCluster CRD property called maxUnavailable in:

  1. spec.vmstorage.rollingUpdateStrategyBehavior.maxUnavailable
  2. spec.vmselect.rollingUpdateStrategyBehavior.maxUnavailable

It's very similar to this (alpha) feature of Kubernetes:
https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#maximum-unavailable-pods

This PR makes it work with the OnDelete upgrade policy used in the operator by default.

Additionally, this PR makes it available for much older Kubernetes versions or, for example, it makes it finally available for those running GKE clusters that don't support alpha features.

Some examples for the maxUnavailable field:

  1. maxUnavailable: 1 - default, which mostly (see details on PDBs below) follows the current behavior of the operator.
  2. maxUnavailable: 2 - for cases when -replicationFactor=3.
  3. maxUnavailable: 100% - for cases when the "minimum downtime strategy" is preferable.

Since more than one pod can now become unavailable during an upgrade (i.e. voluntary disruptions) it's important to respect a PDB configuration to some degree. So this PR introduces a partial support for PDBs targeted at StatefulSets of VMCluster according to this:
https://kubernetes.io/docs/tasks/run-application/configure-pdb/#arbitrary-controllers-and-selectors

This is achieved with the Eviction API instead of directly deleting Pods, as described here:
https://kubernetes.io/docs/concepts/scheduling-eviction/api-eviction/

And since it appears that "write" RBAC permission for Pods is no longer needed, I've moved it to the "read-only" section.


Please let me know if this makes sense!

@vpedosyuk vpedosyuk marked this pull request as ready for review July 7, 2025 11:52
Copy link
Collaborator

@f41gh7 f41gh7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request, it looks good to me!

Could you please mention new API field at docs/CHANGELOG.md as a feature?

Also, it looks like this PR fixes possible issue with breaching of PodDisruption policy by using Eviction instead of Delete

Copy link
Collaborator

@f41gh7 f41gh7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@f41gh7 f41gh7 merged commit b0afe6f into VictoriaMetrics:master Jul 8, 2025
@f41gh7
Copy link
Collaborator

f41gh7 commented Jul 8, 2025

Thanks for contribution!

f41gh7 added a commit that referenced this pull request Jul 9, 2025
Previously operator perform pod deletion without check for PodDisruptionBudget interption.

It was fixed at #1458

Signed-off-by: f41gh7 <nik@victoriametrics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vmcluster: minimum downtime strategy

2 participants