Skip to content

Commit a5ad247

Browse files
authored
feat: Supports upper-layer modification of the InstanceSet's UpdateStrategy (#7978)
Signed-off-by: Liang Deng <[email protected]>
1 parent bb4fbb1 commit a5ad247

28 files changed

+433
-148
lines changed

apis/apps/v1alpha1/cluster_types.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,25 @@ type UserResourceRefs struct {
384384
ConfigMapRefs []ConfigMapRef `json:"configMapRefs,omitempty"`
385385
}
386386

387+
// InstanceUpdateStrategy indicates the strategy that the InstanceSet
388+
// controller will use to perform updates.
389+
type InstanceUpdateStrategy struct {
390+
// Partition indicates the number of pods that should be updated during a rolling update.
391+
// The remaining pods will remain untouched. This is helpful in defining how many pods
392+
// should participate in the update process. The update process will follow the order
393+
// of pod names in descending lexicographical (dictionary) order. The default value is
394+
// ComponentSpec.Replicas (i.e., update all pods).
395+
// +optional
396+
Partition *int32 `json:"partition,omitempty"`
397+
// The maximum number of pods that can be unavailable during the update.
398+
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
399+
// Absolute number is calculated from percentage by rounding up. This can not be 0.
400+
// Defaults to 1. The field applies to all pods. That means if there is any unavailable pod,
401+
// it will be counted towards MaxUnavailable.
402+
// +optional
403+
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
404+
}
405+
387406
// InstanceTemplate allows customization of individual replica configurations in a Component.
388407
type InstanceTemplate struct {
389408
// Name specifies the unique name of the instance Pod created using this InstanceTemplate.
@@ -784,6 +803,13 @@ type ClusterComponentSpec struct {
784803
// +optional
785804
UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`
786805

806+
// Indicates the InstanceUpdateStrategy that will be
807+
// employed to update Pods in the InstanceSet when a revision is made to
808+
// Template.
809+
//
810+
// +optional
811+
InstanceUpdateStrategy *InstanceUpdateStrategy `json:"instanceUpdateStrategy,omitempty"`
812+
787813
// Controls the concurrency of pods during initial scale up, when replacing pods on nodes,
788814
// or when scaling down. It only used when `PodManagementPolicy` is set to `Parallel`.
789815
// The default Concurrency is 100%.

apis/apps/v1alpha1/component_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ type ComponentSpec struct {
173173
// +optional
174174
ServiceAccountName string `json:"serviceAccountName,omitempty"`
175175

176+
// Indicates the InstanceUpdateStrategy that will be
177+
// employed to update Pods in the InstanceSet when a revision is made to
178+
// Template.
179+
//
180+
// +optional
181+
InstanceUpdateStrategy *InstanceUpdateStrategy `json:"instanceUpdateStrategy,omitempty"`
182+
176183
// Controls the concurrency of pods during initial scale up, when replacing pods on nodes,
177184
// or when scaling down. It only used when `PodManagementPolicy` is set to `Parallel`.
178185
// The default Concurrency is 100%.

apis/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/workloads/v1alpha1/instanceset_types.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,35 @@ type SchedulingPolicy struct {
7575
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
7676
}
7777

78+
// InstanceUpdateStrategy indicates the strategy that the InstanceSet
79+
// controller will use to perform updates. It includes any additional parameters
80+
// necessary to perform the update for the indicated strategy.
81+
type InstanceUpdateStrategy struct {
82+
// Partition indicates the number of pods that should be updated during a rolling update.
83+
// The remaining pods will remain untouched. This is helpful in defining how many pods
84+
// should participate in the update process. The update process will follow the order
85+
// of pod names in descending lexicographical (dictionary) order. The default value is
86+
// Replicas (i.e., update all pods).
87+
// +optional
88+
Partition *int32 `json:"partition,omitempty"`
89+
// The maximum number of pods that can be unavailable during the update.
90+
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
91+
// Absolute number is calculated from percentage by rounding up. This can not be 0.
92+
// Defaults to 1. The field applies to all pods. That means if there is any unavailable pod,
93+
// it will be counted towards MaxUnavailable.
94+
// +optional
95+
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
96+
// Members(Pods) update strategy.
97+
//
98+
// - serial: update Members one by one that guarantee minimum component unavailable time.
99+
// - bestEffortParallel: update Members in parallel that guarantee minimum component un-writable time.
100+
// - parallel: force parallel
101+
//
102+
// +kubebuilder:validation:Enum={Serial,BestEffortParallel,Parallel}
103+
// +optional
104+
MemberUpdateStrategy *MemberUpdateStrategy `json:"memberUpdateStrategy,omitempty"`
105+
}
106+
78107
// Range represents a range with a start and an end value.
79108
// It is used to define a continuous segment.
80109
type Range struct {
@@ -326,10 +355,9 @@ type InstanceSetSpec struct {
326355
// Indicates the StatefulSetUpdateStrategy that will be
327356
// employed to update Pods in the InstanceSet when a revision is made to
328357
// Template.
329-
// UpdateStrategy.Type will be set to appsv1.OnDeleteStatefulSetStrategyType if MemberUpdateStrategy is not nil
330358
//
331359
// Note: This field will be removed in future version.
332-
UpdateStrategy appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
360+
UpdateStrategy *InstanceUpdateStrategy `json:"updateStrategy,omitempty"`
333361

334362
// A list of roles defined in the system.
335363
//
@@ -348,11 +376,13 @@ type InstanceSetSpec struct {
348376

349377
// Members(Pods) update strategy.
350378
//
379+
// Deprecated since v0.9.0
351380
// - serial: update Members one by one that guarantee minimum component unavailable time.
352381
// - bestEffortParallel: update Members in parallel that guarantee minimum component un-writable time.
353382
// - parallel: force parallel
354383
//
355384
// +kubebuilder:validation:Enum={Serial,BestEffortParallel,Parallel}
385+
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 0.9.0"
356386
// +optional
357387
MemberUpdateStrategy *MemberUpdateStrategy `json:"memberUpdateStrategy,omitempty"`
358388

apis/workloads/v1alpha1/zz_generated.deepcopy.go

Lines changed: 35 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/apps.kubeblocks.io_clusters.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,33 @@ spec:
594594
- name
595595
type: object
596596
type: array
597+
instanceUpdateStrategy:
598+
description: |-
599+
Indicates the InstanceUpdateStrategy that will be
600+
employed to update Pods in the InstanceSet when a revision is made to
601+
Template.
602+
properties:
603+
maxUnavailable:
604+
anyOf:
605+
- type: integer
606+
- type: string
607+
description: |-
608+
The maximum number of pods that can be unavailable during the update.
609+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
610+
Absolute number is calculated from percentage by rounding up. This can not be 0.
611+
Defaults to 1. The field applies to all pods. That means if there is any unavailable pod,
612+
it will be counted towards MaxUnavailable.
613+
x-kubernetes-int-or-string: true
614+
partition:
615+
description: |-
616+
Partition indicates the number of pods that should be updated during a rolling update.
617+
The remaining pods will remain untouched. This is helpful in defining how many pods
618+
should participate in the update process. The update process will follow the order
619+
of pod names in descending lexicographical (dictionary) order. The default value is
620+
ComponentSpec.Replicas (i.e., update all pods).
621+
format: int32
622+
type: integer
623+
type: object
597624
instances:
598625
description: |-
599626
Allows for the customization of configuration values for each instance within a Component.
@@ -7110,6 +7137,33 @@ spec:
71107137
- name
71117138
type: object
71127139
type: array
7140+
instanceUpdateStrategy:
7141+
description: |-
7142+
Indicates the InstanceUpdateStrategy that will be
7143+
employed to update Pods in the InstanceSet when a revision is made to
7144+
Template.
7145+
properties:
7146+
maxUnavailable:
7147+
anyOf:
7148+
- type: integer
7149+
- type: string
7150+
description: |-
7151+
The maximum number of pods that can be unavailable during the update.
7152+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
7153+
Absolute number is calculated from percentage by rounding up. This can not be 0.
7154+
Defaults to 1. The field applies to all pods. That means if there is any unavailable pod,
7155+
it will be counted towards MaxUnavailable.
7156+
x-kubernetes-int-or-string: true
7157+
partition:
7158+
description: |-
7159+
Partition indicates the number of pods that should be updated during a rolling update.
7160+
The remaining pods will remain untouched. This is helpful in defining how many pods
7161+
should participate in the update process. The update process will follow the order
7162+
of pod names in descending lexicographical (dictionary) order. The default value is
7163+
ComponentSpec.Replicas (i.e., update all pods).
7164+
format: int32
7165+
type: integer
7166+
type: object
71137167
instances:
71147168
description: |-
71157169
Allows for the customization of configuration values for each instance within a Component.

config/crd/bases/apps.kubeblocks.io_components.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,33 @@ spec:
524524
- name
525525
type: object
526526
type: array
527+
instanceUpdateStrategy:
528+
description: |-
529+
Indicates the InstanceUpdateStrategy that will be
530+
employed to update Pods in the InstanceSet when a revision is made to
531+
Template.
532+
properties:
533+
maxUnavailable:
534+
anyOf:
535+
- type: integer
536+
- type: string
537+
description: |-
538+
The maximum number of pods that can be unavailable during the update.
539+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
540+
Absolute number is calculated from percentage by rounding up. This can not be 0.
541+
Defaults to 1. The field applies to all pods. That means if there is any unavailable pod,
542+
it will be counted towards MaxUnavailable.
543+
x-kubernetes-int-or-string: true
544+
partition:
545+
description: |-
546+
Partition indicates the number of pods that should be updated during a rolling update.
547+
The remaining pods will remain untouched. This is helpful in defining how many pods
548+
should participate in the update process. The update process will follow the order
549+
of pod names in descending lexicographical (dictionary) order. The default value is
550+
ComponentSpec.Replicas (i.e., update all pods).
551+
format: int32
552+
type: integer
553+
type: object
527554
instances:
528555
description: |-
529556
Allows for the customization of configuration values for each instance within a Component.

0 commit comments

Comments
 (0)