Skip to content

Commit 4cddc13

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

27 files changed

+471
-195
lines changed

apis/apps/v1alpha1/cluster_types.go

+17-7
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,19 @@ 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. It includes any additional parameters
399+
// necessary to perform the update for the indicated strategy.
400+
type InstanceUpdateStrategy struct {
401+
// Type indicates the type of the InstanceUpdateStrategy.
402+
// Default is RollingUpdate.
403+
// +optional
404+
Type workloads.InstanceSetUpdateStrategyType `json:"type,omitempty"`
405+
// RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.
406+
// +optional
407+
RollingUpdate *workloads.RollingUpdateStrategy `json:"rollingUpdate,omitempty"`
408+
}
409+
397410
// InstanceTemplate allows customization of individual replica configurations in a Component.
398411
type InstanceTemplate struct {
399412
// Name specifies the unique name of the instance Pod created using this InstanceTemplate.
@@ -790,15 +803,12 @@ type ClusterComponentSpec struct {
790803
// +optional
791804
ServiceAccountName string `json:"serviceAccountName,omitempty"`
792805

793-
// Defines the update strategy for the Component.
806+
// Indicates the InstanceUpdateStrategy that will be
807+
// employed to update Pods in the InstanceSet when a revision is made to
808+
// Template.
794809
//
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"
800810
// +optional
801-
UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`
811+
InstanceUpdateStrategy InstanceUpdateStrategy `json:"instanceUpdateStrategy,omitempty"`
802812

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

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

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

apis/workloads/v1alpha1/instanceset_types.go

+62-12
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,66 @@ type SchedulingPolicy struct {
7575
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
7676
}
7777

78+
// InstanceSetUpdateStrategyType is a string enumeration type that enumerates
79+
// all possible update strategies for the InstanceSet controller.
80+
// +enum
81+
type InstanceSetUpdateStrategyType string
82+
83+
const (
84+
// RollingUpdateInstanceSetStrategyType indicates that update will be
85+
// applied to all Pods in the InstanceSet with respect to the InstanceSet
86+
// ordering constraints. When a scale operation is performed with this
87+
// strategy, new Pods will be created from the specification version indicated
88+
// by the InstanceSet's updateRevision.
89+
RollingUpdateInstanceSetStrategyType InstanceSetUpdateStrategyType = "RollingUpdate"
90+
// OnDeleteInstanceSetStrategyType triggers the legacy behavior. Version
91+
// tracking and ordered rolling restarts are disabled. Pods are recreated
92+
// when they are manually deleted. When a scale
93+
// operation is performed with this strategy, specification version indicated
94+
// by the InstanceSet's currentRevision.
95+
OnDeleteInstanceSetStrategyType InstanceSetUpdateStrategyType = "OnDelete"
96+
)
97+
98+
// InstanceUpdateStrategy indicates the strategy that the InstanceSet
99+
// controller will use to perform updates. It includes any additional parameters
100+
// necessary to perform the update for the indicated strategy.
101+
type InstanceUpdateStrategy struct {
102+
// Type indicates the type of the InstanceUpdateStrategy.
103+
// Default is RollingUpdate.
104+
// +optional
105+
Type InstanceSetUpdateStrategyType `json:"type,omitempty"`
106+
// RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.
107+
// +optional
108+
RollingUpdate *RollingUpdateStrategy `json:"rollingUpdate,omitempty"`
109+
// Members(Pods) update strategy.
110+
//
111+
// - serial: update Members one by one that guarantee minimum component unavailable time.
112+
// - bestEffortParallel: update Members in parallel that guarantee minimum component un-writable time.
113+
// - parallel: force parallel
114+
//
115+
// +kubebuilder:validation:Enum={Serial,BestEffortParallel,Parallel}
116+
// +optional
117+
MemberUpdateStrategy *MemberUpdateStrategy `json:"memberUpdateStrategy,omitempty"`
118+
}
119+
120+
// RollingUpdateStrategy is used to communicate parameter for RollingUpdateInstanceSetStrategyType.
121+
type RollingUpdateStrategy struct {
122+
// Partition indicates the ordinal at which the InstanceSet should be partitioned
123+
// for updates. During a rolling update, all pods from ordinal Replicas-1 to
124+
// Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched.
125+
// This is helpful in being able to do a canary based deployment. The default value is 0.
126+
// +optional
127+
Partition *int32 `json:"partition,omitempty"`
128+
// The maximum number of pods that can be unavailable during the update.
129+
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
130+
// Absolute number is calculated from percentage by rounding up. This can not be 0.
131+
// Defaults to 1. The field applies to all pods in the range 0 to Replicas-1.
132+
// That means if there is any unavailable pod in the range 0 to Replicas-1,
133+
// it will be counted towards MaxUnavailable.
134+
// +optional
135+
MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"`
136+
}
137+
78138
// Range represents a range with a start and an end value.
79139
// It is used to define a continuous segment.
80140
type Range struct {
@@ -326,10 +386,10 @@ type InstanceSetSpec struct {
326386
// Indicates the StatefulSetUpdateStrategy that will be
327387
// employed to update Pods in the InstanceSet when a revision is made to
328388
// Template.
329-
// UpdateStrategy.Type will be set to appsv1.OnDeleteStatefulSetStrategyType if MemberUpdateStrategy is not nil
389+
// UpdateStrategy.Type will be set to OnDeleteInstanceSetStrategyType if UpdateStrategy.MemberUpdateStrategy is not nil
330390
//
331391
// Note: This field will be removed in future version.
332-
UpdateStrategy appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
392+
UpdateStrategy InstanceUpdateStrategy `json:"updateStrategy,omitempty"`
333393

334394
// A list of roles defined in the system.
335395
//
@@ -346,16 +406,6 @@ type InstanceSetSpec struct {
346406
// +optional
347407
MembershipReconfiguration *MembershipReconfiguration `json:"membershipReconfiguration,omitempty"`
348408

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-
359409
// Indicates that the InstanceSet is paused, meaning the reconciliation of this InstanceSet object will be paused.
360410
// +optional
361411
Paused bool `json:"paused,omitempty"`

apis/workloads/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)