Skip to content

Commit

Permalink
Support maxSurge in rolling update
Browse files Browse the repository at this point in the history
Signed-off-by: kerthcet <[email protected]>
  • Loading branch information
kerthcet committed Apr 30, 2024
1 parent 78268be commit 229a677
Show file tree
Hide file tree
Showing 15 changed files with 1,019 additions and 190 deletions.
20 changes: 20 additions & 0 deletions api/leaderworkerset/v1/leaderworkerset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const (
// LeaderWorkerSet.Spec.LeaderWorkerTemplate.Size.
SizeAnnotationKey string = "leaderworkerset.sigs.k8s.io/size"

// Replicas will be added to leader statefulset as an annotation which corresponds to
// LeaderWorkerSet.Spec.Replicas
ReplicasAnnotationKey string = "leaderworkerset.sigs.k8s.io/replicas"

// Pods that are in the same group will have an annotation that is a unique
// hash value.
GroupUniqueHashLabelKey string = "leaderworkerset.sigs.k8s.io/group-key"
Expand Down Expand Up @@ -145,6 +149,22 @@ type RollingUpdateConfiguration struct {
// +kubebuilder:validation:XIntOrString
// +kubebuilder:default=1
MaxUnavailable intstr.IntOrString `json:"maxUnavailable,omitempty"`

// The maximum number of replicas that can be scheduled above the original number of
// replicas.
// Value can be an absolute number (ex: 5) or a percentage of total replicas at
// the start of the update (ex: 10%).
// Absolute number is calculated from percentage by rounding up.
// By default, a value of 0 is used.
// Example: when this is set to 30%, the new replicas can be scaled up by 30%
// immediately when the rolling update starts. Once old replicas have been deleted,
// new replicas can be scaled up further, ensuring that total number of replicas running
// at any time during the update is at most 130% of original replicas.
// When rolling update completes, replicas will fall back to the original replicas.
//
// +kubebuilder:validation:XIntOrString
// +kubebuilder:default=0
MaxSurge intstr.IntOrString `json:"maxSurge,omitempty"`
}

type RolloutStrategyType string
Expand Down
1 change: 1 addition & 0 deletions api/leaderworkerset/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions config/crd/bases/leaderworkerset.x-k8s.io_leaderworkersets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15279,6 +15279,24 @@ spec:
description: RollingUpdateConfiguration defines the parameters
to be used when type is RollingUpdateStrategyType.
properties:
maxSurge:
anyOf:
- type: integer
- type: string
default: 0
description: |-
The maximum number of replicas that can be scheduled above the original number of
replicas.
Value can be an absolute number (ex: 5) or a percentage of total replicas at
the start of the update (ex: 10%).
Absolute number is calculated from percentage by rounding up.
By default, a value of 0 is used.
Example: when this is set to 30%, the new replicas can be scaled up by 30%
immediately when the rolling update starts. Once old replicas have been deleted,
new replicas can be scaled up further, ensuring that total number of replicas running
at any time during the update is at most 130% of original replicas.
When rolling update completes, replicas will fall back to the original replicas.
x-kubernetes-int-or-string: true
maxUnavailable:
anyOf:
- type: integer
Expand Down
Loading

0 comments on commit 229a677

Please sign in to comment.