Skip to content

Commit f84bd1e

Browse files
committed
feat: Supports upper-layer modification of the InstanceSet's UpdateStrategy
Signed-off-by: Liang Deng <[email protected]>
1 parent 4b19c5f commit f84bd1e

28 files changed

+406
-160
lines changed

apis/apps/v1alpha1/cluster_types.go

+26
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.
@@ -800,6 +819,13 @@ type ClusterComponentSpec struct {
800819
// +optional
801820
UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`
802821

822+
// Indicates the InstanceUpdateStrategy that will be
823+
// employed to update Pods in the InstanceSet when a revision is made to
824+
// Template.
825+
//
826+
// +optional
827+
InstanceUpdateStrategy InstanceUpdateStrategy `json:"instanceUpdateStrategy,omitempty"`
828+
803829
// Controls the concurrency of pods during initial scale up, when replacing pods on nodes,
804830
// or when scaling down. It only used when `PodManagementPolicy` is set to `Parallel`.
805831
// The default Concurrency is 100%.

apis/apps/v1alpha1/component_types.go

+7
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

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/workloads/v1alpha1/instanceset_types.go

+32-2
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
//
@@ -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

+30
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

+54
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.
@@ -9772,6 +9799,33 @@ spec:
97729799
- name
97739800
type: object
97749801
type: array
9802+
instanceUpdateStrategy:
9803+
description: |-
9804+
Indicates the InstanceUpdateStrategy that will be
9805+
employed to update Pods in the InstanceSet when a revision is made to
9806+
Template.
9807+
properties:
9808+
maxUnavailable:
9809+
anyOf:
9810+
- type: integer
9811+
- type: string
9812+
description: |-
9813+
The maximum number of pods that can be unavailable during the update.
9814+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
9815+
Absolute number is calculated from percentage by rounding up. This can not be 0.
9816+
Defaults to 1. The field applies to all pods in the range 0 to Replicas-1.
9817+
That means if there is any unavailable pod in the range 0 to Replicas-1,
9818+
it will be counted towards MaxUnavailable.
9819+
x-kubernetes-int-or-string: true
9820+
partition:
9821+
description: |-
9822+
Partition indicates the ordinal at which the InstanceSet should be partitioned
9823+
for updates. During a rolling update, all pods from ordinal Replicas-1 to
9824+
Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
9825+
This is helpful in being able to do a canary based deployment. The default value is 0.
9826+
format: int32
9827+
type: integer
9828+
type: object
97759829
instances:
97769830
description: |-
97779831
Allows for the customization of configuration values for each instance within a Component.

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

+27
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.

config/crd/bases/workloads.kubeblocks.io_instancesets.yaml

+32-30
Original file line numberDiff line numberDiff line change
@@ -3947,6 +3947,7 @@ spec:
39473947
Members(Pods) update strategy.
39483948

39493949

3950+
Deprecated since v0.9.0
39503951
- serial: update Members one by one that guarantee minimum component unavailable time.
39513952
- bestEffortParallel: update Members in parallel that guarantee minimum component un-writable time.
39523953
- parallel: force parallel
@@ -12391,42 +12392,43 @@ spec:
1239112392
Indicates the StatefulSetUpdateStrategy that will be
1239212393
employed to update Pods in the InstanceSet when a revision is made to
1239312394
Template.
12394-
UpdateStrategy.Type will be set to appsv1.OnDeleteStatefulSetStrategyType if MemberUpdateStrategy is not nil
1239512395

1239612396

1239712397
Note: This field will be removed in future version.
1239812398
properties:
12399-
rollingUpdate:
12400-
description: RollingUpdate is used to communicate parameters when
12401-
Type is RollingUpdateStatefulSetStrategyType.
12402-
properties:
12403-
maxUnavailable:
12404-
anyOf:
12405-
- type: integer
12406-
- type: string
12407-
description: |-
12408-
The maximum number of pods that can be unavailable during the update.
12409-
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
12410-
Absolute number is calculated from percentage by rounding up. This can not be 0.
12411-
Defaults to 1. This field is alpha-level and is only honored by servers that enable the
12412-
MaxUnavailableStatefulSet feature. The field applies to all pods in the range 0 to
12413-
Replicas-1. That means if there is any unavailable pod in the range 0 to Replicas-1, it
12414-
will be counted towards MaxUnavailable.
12415-
x-kubernetes-int-or-string: true
12416-
partition:
12417-
description: |-
12418-
Partition indicates the ordinal at which the StatefulSet should be partitioned
12419-
for updates. During a rolling update, all pods from ordinal Replicas-1 to
12420-
Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
12421-
This is helpful in being able to do a canary based deployment. The default value is 0.
12422-
format: int32
12423-
type: integer
12424-
type: object
12425-
type:
12399+
maxUnavailable:
12400+
anyOf:
12401+
- type: integer
12402+
- type: string
12403+
description: |-
12404+
The maximum number of pods that can be unavailable during the update.
12405+
Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
12406+
Absolute number is calculated from percentage by rounding up. This can not be 0.
12407+
Defaults to 1. The field applies to all pods in the range 0 to Replicas-1.
12408+
That means if there is any unavailable pod in the range 0 to Replicas-1,
12409+
it will be counted towards MaxUnavailable.
12410+
x-kubernetes-int-or-string: true
12411+
memberUpdateStrategy:
1242612412
description: |-
12427-
Type indicates the type of the StatefulSetUpdateStrategy.
12428-
Default is RollingUpdate.
12413+
Members(Pods) update strategy.
12414+
12415+
12416+
- serial: update Members one by one that guarantee minimum component unavailable time.
12417+
- bestEffortParallel: update Members in parallel that guarantee minimum component un-writable time.
12418+
- parallel: force parallel
12419+
enum:
12420+
- Serial
12421+
- BestEffortParallel
12422+
- Parallel
1242912423
type: string
12424+
partition:
12425+
description: |-
12426+
Partition indicates the ordinal at which the InstanceSet should be partitioned
12427+
for updates. During a rolling update, all pods from ordinal Replicas-1 to
12428+
Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
12429+
This is helpful in being able to do a canary based deployment. The default value is 0.
12430+
format: int32
12431+
type: integer
1243012432
type: object
1243112433
volumeClaimTemplates:
1243212434
description: |-

0 commit comments

Comments
 (0)