Skip to content

Commit c33642b

Browse files
committed
feat: Supports upper-layer modification of the InstanceSet's UpdateStrategy
Signed-off-by: Liang Deng <283304489@qq.com>
1 parent 99cb59e commit c33642b

28 files changed

+394
-281
lines changed

apis/apps/v1alpha1/cluster_types.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,25 @@ type UserResourceRefs struct {
394394
ConfigMapRefs []ConfigMapRef `json:"configMapRefs,omitempty"`
395395
}
396396

397+
// InstanceUpdateStrategy indicates the strategy that the InstanceSet
398+
// controller will use to perform updates.
399+
type InstanceUpdateStrategy struct {
400+
// Partition indicates the ordinal at which the InstanceSet should be partitioned
401+
// for updates. During a rolling update, all pods from ordinal Replicas-1 to
402+
// Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
403+
// This is helpful in being able to do a canary based deployment. The default value is 0.
404+
// +optional
405+
Partition *int32 `json:"partition,omitempty"`
406+
// The maximum number of pods that can be unavailable during the update.
407+
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
408+
// Absolute number is calculated from percentage by rounding up. This can not be 0.
409+
// Defaults to 1. The field applies to all pods in the range 0 to Replicas-1.
410+
// That means if there is any unavailable pod in the range 0 to Replicas-1,
411+
// it will be counted towards MaxUnavailable.
412+
// +optional
413+
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
414+
}
415+
397416
// InstanceTemplate allows customization of individual replica configurations in a Component.
398417
type InstanceTemplate struct {
399418
// Name specifies the unique name of the instance Pod created using this InstanceTemplate.
@@ -790,15 +809,12 @@ type ClusterComponentSpec struct {
790809
// +optional
791810
ServiceAccountName string `json:"serviceAccountName,omitempty"`
792811

793-
// Defines the update strategy for the Component.
812+
// Indicates the InstanceUpdateStrategy that will be
813+
// employed to update Pods in the InstanceSet when a revision is made to
814+
// Template.
794815
//
795-
// Deprecated since v0.9.
796-
// This field is maintained for backward compatibility and its use is discouraged.
797-
// Existing usage should be updated to the current preferred approach to avoid compatibility issues in future releases.
798-
//
799-
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 0.9.0"
800816
// +optional
801-
UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`
817+
InstanceUpdateStrategy InstanceUpdateStrategy `json:"instanceUpdateStrategy,omitempty"`
802818

803819
// Controls the concurrency of pods during initial scale up, when replacing pods on nodes,
804820
// or when scaling down. It only used when `PodManagementPolicy` is set to `Parallel`.

apis/apps/v1alpha1/component_types.go

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

166+
// Indicates the InstanceUpdateStrategy that will be
167+
// employed to update Pods in the InstanceSet when a revision is made to
168+
// Template.
169+
//
170+
// +optional
171+
InstanceUpdateStrategy InstanceUpdateStrategy `json:"instanceUpdateStrategy,omitempty"`
172+
166173
// Controls the concurrency of pods during initial scale up, when replacing pods on nodes,
167174
// or when scaling down. It only used when `PodManagementPolicy` is set to `Parallel`.
168175
// The default Concurrency is 100%.

apis/apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 27 additions & 5 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: 30 additions & 12 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 ordinal at which the InstanceSet should be partitioned
83+
// for updates. During a rolling update, all pods from ordinal Replicas-1 to
84+
// Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
85+
// This is helpful in being able to do a canary based deployment. The default value is 0.
86+
// +optional
87+
Partition *int32 `json:"partition,omitempty"`
88+
// The maximum number of pods that can be unavailable during the update.
89+
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
90+
// Absolute number is calculated from percentage by rounding up. This can not be 0.
91+
// Defaults to 1. The field applies to all pods in the range 0 to Replicas-1.
92+
// That means if there is any unavailable pod in the range 0 to Replicas-1,
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
//
@@ -346,16 +374,6 @@ type InstanceSetSpec struct {
346374
// +optional
347375
MembershipReconfiguration *MembershipReconfiguration `json:"membershipReconfiguration,omitempty"`
348376

349-
// Members(Pods) update strategy.
350-
//
351-
// - serial: update Members one by one that guarantee minimum component unavailable time.
352-
// - bestEffortParallel: update Members in parallel that guarantee minimum component un-writable time.
353-
// - parallel: force parallel
354-
//
355-
// +kubebuilder:validation:Enum={Serial,BestEffortParallel,Parallel}
356-
// +optional
357-
MemberUpdateStrategy *MemberUpdateStrategy `json:"memberUpdateStrategy,omitempty"`
358-
359377
// Indicates that the InstanceSet is paused, meaning the reconciliation of this InstanceSet object will be paused.
360378
// +optional
361379
Paused bool `json:"paused,omitempty"`

apis/workloads/v1alpha1/zz_generated.deepcopy.go

Lines changed: 30 additions & 5 deletions
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 & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,33 @@ spec:
655655
- name
656656
type: object
657657
type: array
658+
instanceUpdateStrategy:
659+
description: |-
660+
Indicates the InstanceUpdateStrategy that will be
661+
employed to update Pods in the InstanceSet when a revision is made to
662+
Template.
663+
properties:
664+
maxUnavailable:
665+
anyOf:
666+
- type: integer
667+
- type: string
668+
description: |-
669+
The maximum number of pods that can be unavailable during the update.
670+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
671+
Absolute number is calculated from percentage by rounding up. This can not be 0.
672+
Defaults to 1. The field applies to all pods in the range 0 to Replicas-1.
673+
That means if there is any unavailable pod in the range 0 to Replicas-1,
674+
it will be counted towards MaxUnavailable.
675+
x-kubernetes-int-or-string: true
676+
partition:
677+
description: |-
678+
Partition indicates the ordinal at which the InstanceSet should be partitioned
679+
for updates. During a rolling update, all pods from ordinal Replicas-1 to
680+
Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
681+
This is helpful in being able to do a canary based deployment. The default value is 0.
682+
format: int32
683+
type: integer
684+
type: object
658685
instances:
659686
description: |-
660687
Allows for the customization of configuration values for each instance within a Component.
@@ -5680,19 +5707,6 @@ spec:
56805707
type: object
56815708
type: array
56825709
x-kubernetes-preserve-unknown-fields: true
5683-
updateStrategy:
5684-
description: |-
5685-
Defines the update strategy for the Component.
5686-
5687-
5688-
Deprecated since v0.9.
5689-
This field is maintained for backward compatibility and its use is discouraged.
5690-
Existing usage should be updated to the current preferred approach to avoid compatibility issues in future releases.
5691-
enum:
5692-
- Serial
5693-
- BestEffortParallel
5694-
- Parallel
5695-
type: string
56965710
userResourceRefs:
56975711
description: |-
56985712
Allows users to specify custom ConfigMaps and Secrets to be mounted as volumes
@@ -9772,6 +9786,33 @@ spec:
97729786
- name
97739787
type: object
97749788
type: array
9789+
instanceUpdateStrategy:
9790+
description: |-
9791+
Indicates the InstanceUpdateStrategy that will be
9792+
employed to update Pods in the InstanceSet when a revision is made to
9793+
Template.
9794+
properties:
9795+
maxUnavailable:
9796+
anyOf:
9797+
- type: integer
9798+
- type: string
9799+
description: |-
9800+
The maximum number of pods that can be unavailable during the update.
9801+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
9802+
Absolute number is calculated from percentage by rounding up. This can not be 0.
9803+
Defaults to 1. The field applies to all pods in the range 0 to Replicas-1.
9804+
That means if there is any unavailable pod in the range 0 to Replicas-1,
9805+
it will be counted towards MaxUnavailable.
9806+
x-kubernetes-int-or-string: true
9807+
partition:
9808+
description: |-
9809+
Partition indicates the ordinal at which the InstanceSet should be partitioned
9810+
for updates. During a rolling update, all pods from ordinal Replicas-1 to
9811+
Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
9812+
This is helpful in being able to do a canary based deployment. The default value is 0.
9813+
format: int32
9814+
type: integer
9815+
type: object
97759816
instances:
97769817
description: |-
97779818
Allows for the customization of configuration values for each instance within a Component.
@@ -14859,19 +14900,6 @@ spec:
1485914900
type: object
1486014901
type: array
1486114902
x-kubernetes-preserve-unknown-fields: true
14862-
updateStrategy:
14863-
description: |-
14864-
Defines the update strategy for the Component.
14865-
14866-
14867-
Deprecated since v0.9.
14868-
This field is maintained for backward compatibility and its use is discouraged.
14869-
Existing usage should be updated to the current preferred approach to avoid compatibility issues in future releases.
14870-
enum:
14871-
- Serial
14872-
- BestEffortParallel
14873-
- Parallel
14874-
type: string
1487514903
userResourceRefs:
1487614904
description: |-
1487714905
Allows users to specify custom ConfigMaps and Secrets to be mounted as volumes

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,33 @@ spec:
401401
- name
402402
type: object
403403
type: array
404+
instanceUpdateStrategy:
405+
description: |-
406+
Indicates the InstanceUpdateStrategy that will be
407+
employed to update Pods in the InstanceSet when a revision is made to
408+
Template.
409+
properties:
410+
maxUnavailable:
411+
anyOf:
412+
- type: integer
413+
- type: string
414+
description: |-
415+
The maximum number of pods that can be unavailable during the update.
416+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
417+
Absolute number is calculated from percentage by rounding up. This can not be 0.
418+
Defaults to 1. The field applies to all pods in the range 0 to Replicas-1.
419+
That means if there is any unavailable pod in the range 0 to Replicas-1,
420+
it will be counted towards MaxUnavailable.
421+
x-kubernetes-int-or-string: true
422+
partition:
423+
description: |-
424+
Partition indicates the ordinal at which the InstanceSet should be partitioned
425+
for updates. During a rolling update, all pods from ordinal Replicas-1 to
426+
Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
427+
This is helpful in being able to do a canary based deployment. The default value is 0.
428+
format: int32
429+
type: integer
430+
type: object
404431
instances:
405432
description: |-
406433
Allows for the customization of configuration values for each instance within a Component.

0 commit comments

Comments
 (0)