Update maxUnavailable calculation for leader StatefulSet#781
Merged
k8s-ci-robot merged 2 commits intokubernetes-sigs:mainfrom Mar 24, 2026
Merged
Update maxUnavailable calculation for leader StatefulSet#781k8s-ci-robot merged 2 commits intokubernetes-sigs:mainfrom
k8s-ci-robot merged 2 commits intokubernetes-sigs:mainfrom
Conversation
✅ Deploy Preview for kubernetes-sigs-lws canceled.
|
Contributor
Author
|
/test pull-lws-test-integration-main |
6ab6747 to
d0bd35d
Compare
Contributor
Author
|
/test pull-lws-test-integration-main |
Edwinhr716
reviewed
Mar 20, 2026
Contributor
|
/lgtm Will approve once #778 is merged |
d0bd35d to
334fa23
Compare
e48ee1f to
593e598
Compare
Contributor
Author
|
/test pull-lws-test-integration-main |
bc10356 to
41902a5
Compare
5404398 to
cee8148
Compare
Fix maxSurge calculation to be capped at lws.replicas, and evaluate percentages against sts.replicas rather than lws.replicas. Also add unit tests to prevent regressions.
cee8148 to
0aa7d94
Compare
Contributor
|
/lgtm |
Contributor
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adinilfeld, Edwinhr716 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
What type of PR is this?
/kind feature
What this PR does / why we need it
This PR sets the
maxUnavailablevalue of the leader StatefulSet tolws.maxSurge + lws.maxUnavailable, rather than justlws.maxUnavailable. This has two main benefits:Users can now achieve zero-downtime updates by specifying
maxUnavailable=0, as long asmaxSurge>0. Previously, the leader StatefulSet would have rejected this value. (See Support maxUnavailable=0 #776.)Rolling updates now update pods in larger batches, leading to rollouts completing quicker while still respecting the spec.
For instance, the example given in the Rollout Strategy doc previously didn't work as documented. In Stage3, R-2 and R-3 would only begin updating after both surge pods were Ready, as the StatefulSet's
maxUnavailable=2was "used up" by the surge pods. Now it would havemaxUnavailable=4and be able to update as intended. In my testing, this change reduced the rollout time by 30% (from 1m48s to 1m15s).In addition, I made some small tweaks to the logs for clarity.
Which issue(s) this PR fixes
Fixes #776.
Special notes for your reviewer
In addition to unit/e2e/integration tests, I verified the following scenarios manually:
maxUnavailable=0,maxSurge=2: once the two surge pods are Ready, the existing pods are updated two at a time.Full events
maxUnavailable=2,maxSurge=2: the rollout order now matches the example given in the docs.Full events
Does this PR introduce a user-facing change?