Skip to content

Commit f2276ab

Browse files
authored
Merge pull request #5 from KusionStack/update-operating-api-0.1.1
update operating api to v0.1.1
2 parents 015e4c8 + 3cb5116 commit f2276ab

9 files changed

+353
-304
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*.out
1616

1717
# Dependency directories (remove the comment below to include it)
18-
# vendor/
18+
vendor/
1919

2020
# Go workspace file
2121
go.work

apps/v1alpha1/collaset_types.go

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ import (
2424
type CollaSetConditionType string
2525

2626
const (
27-
CollaSetSyncPod CollaSetConditionType = "SyncPod"
28-
CollaSetScale CollaSetConditionType = "Scale"
29-
CollaSetUpdate CollaSetConditionType = "Update"
27+
CollaSetScale CollaSetConditionType = "Scale"
28+
CollaSetUpdate CollaSetConditionType = "Update"
3029
)
3130

3231
// PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine
@@ -98,9 +97,11 @@ type CollaSetSpec struct {
9897
// UpdateStrategy indicates the CollaSetUpdateStrategy that will be
9998
// employed to update Pods in the CollaSet when a revision is made to
10099
// Template.
100+
// +optional
101101
UpdateStrategy UpdateStrategy `json:"updateStrategy,omitempty"`
102102

103103
// ScaleStrategy indicates the strategy detail that will be used during pod scaling.
104+
// +optional
104105
ScaleStrategy ScaleStrategy `json:"scaleStrategy,omitempty"`
105106

106107
// Indicate the number of histories to be conserved
@@ -113,11 +114,15 @@ type ScaleStrategy struct {
113114
// Context indicates the pool from which to allocate Pod instance ID. CollaSets are allowed to share the
114115
// same Context. It is not allowed to change.
115116
// Context defaults to be CollaSet's name.
117+
// +optional
116118
Context string `json:"context,omitempty"`
119+
117120
// PodToExclude indicates the pods which will be orphaned by CollaSet.
121+
// +optional
118122
PodToExclude []string `json:"podToExclude,omitempty"`
119123

120124
// PodToInclude indicates the pods which will be adapted by CollaSet.
125+
// +optional
121126
PodToInclude []string `json:"podToInclude,omitempty"`
122127

123128
// PersistentVolumeClaimRetentionPolicy describes the lifecycle of PersistentVolumeClaim
@@ -126,25 +131,33 @@ type ScaleStrategy struct {
126131
// by deleting persistent volume claims when their CollaSet is deleted, or when their pod is scaled down.
127132
// +optional
128133
PersistentVolumeClaimRetentionPolicy *PersistentVolumeClaimRetentionPolicy `json:"persistentVolumeClaimRetentionPolicy,omitempty"`
134+
135+
// OperationDelaySeconds indicates how many seconds it should delay before operating scale.
136+
// +optional
137+
OperationDelaySeconds *int32 `json:"operationDelaySeconds,omitempty"`
129138
}
130139

131140
type PersistentVolumeClaimRetentionPolicy struct {
132141
// WhenDeleted specifies what happens to PVCs created from CollaSet
133142
// VolumeClaimTemplates when the CollaSet is deleted. The default policy
134143
// of `Delete` policy causes those PVCs to be deleted.
135144
//`Retain` causes PVCs to not be affected by StatefulSet deletion. The
145+
// +optional
136146
WhenDeleted PersistentVolumeClaimRetentionPolicyType `json:"whenDeleted,omitempty"`
147+
137148
// WhenScaled specifies what happens to PVCs created from StatefulSet
138149
// VolumeClaimTemplates when the StatefulSet is scaled down. The default
139150
// policy of `Retain` causes PVCs to not be affected by a scaledown. The
140151
// `Delete` policy causes the associated PVCs for any excess pods above
141152
// the replica count to be deleted.
153+
// +optional
142154
WhenScaled PersistentVolumeClaimRetentionPolicyType `json:"whenScaled,omitempty"`
143155
}
144156

145157
type ByPartition struct {
146158
// Partition controls the update progress by indicating how many pods should be updated.
147159
// Defaults to nil (all pods will be updated)
160+
// +optional
148161
Partition *int32 `json:"partition,omitempty"`
149162
}
150163

@@ -154,19 +167,26 @@ type ByLabel struct {
154167
// RollingUpdateCollaSetStrategy is used to communicate parameter for rolling update.
155168
type RollingUpdateCollaSetStrategy struct {
156169
// ByPartition indicates the update progress is controlled by partition value.
170+
// +optional
157171
ByPartition *ByPartition `json:"byPartition,omitempty"`
158172

159173
// ByLabel indicates the update progress is controlled by attaching pod label.
174+
// +optional
160175
ByLabel *ByLabel `json:"byLabel,omitempty"`
161176
}
162177

163178
type UpdateStrategy struct {
164179
// RollingUpdate is used to communicate parameters when Type is RollingUpdateStatefulSetStrategyType.
180+
// +optional
165181
RollingUpdate *RollingUpdateCollaSetStrategy `json:"rollingUpdate,omitempty"`
166182

167183
// PodUpdatePolicy indicates the policy by to update pods.
168184
// +optional
169185
PodUpdatePolicy PodUpdateStrategyType `json:"podUpgradePolicy,omitempty"`
186+
187+
// OperationDelaySeconds indicates how many seconds it should delay before operating update.
188+
// +optional
189+
OperationDelaySeconds *int32 `json:"operationDelaySeconds,omitempty"`
170190
}
171191

172192
// CollaSetStatus defines the observed state of CollaSet
@@ -177,12 +197,14 @@ type CollaSetStatus struct {
177197
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
178198

179199
// CurrentRevision, if not empty, indicates the version of the CollaSet.
200+
// +optional
180201
CurrentRevision string `json:"currentRevision,omitempty"`
181202

182203
// UpdatedRevision, if not empty, indicates the version of the CollaSet currently updated.
204+
// +optional
183205
UpdatedRevision string `json:"updatedRevision,omitempty"`
184206

185-
// Count of hash collisions for the DaemonSet. The DaemonSet controller
207+
// Count of hash collisions for the CollaSet. The CollaSet controller
186208
// uses this field as a collision avoidance mechanism when it needs to
187209
// create the name for the newest ControllerRevision.
188210
// +optional
@@ -201,12 +223,15 @@ type CollaSetStatus struct {
201223
AvailableReplicas int32 `json:"availableReplicas,omitempty"`
202224

203225
// Replicas is the most recently observed number of replicas.
226+
// +optional
204227
Replicas int32 `json:"replicas,omitempty"`
205228

206229
// The number of pods in updated version.
230+
// +optional
207231
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
208232

209233
// OperatingReplicas indicates the number of pods during pod ops lifecycle and not finish update-phase.
234+
// +optional
210235
OperatingReplicas int32 `json:"operatingReplicas,omitempty"`
211236

212237
// UpdatedReadyReplicas indicates the number of the pod with updated revision and ready condition
@@ -240,8 +265,8 @@ type CollaSetCondition struct {
240265
Message string `json:"message,omitempty"`
241266
}
242267

243-
//+kubebuilder:object:root=true
244-
//+kubebuilder:subresource:status
268+
// +kubebuilder:object:root=true
269+
// +kubebuilder:subresource:status
245270

246271
// CollaSet is the Schema for the collasets API
247272
// +k8s:openapi-gen=true
@@ -250,6 +275,7 @@ type CollaSetCondition struct {
250275
// +kubebuilder:subresource:status
251276
// +kubebuilder:printcolumn:name="DESIRED",type="integer",JSONPath=".spec.replicas",description="The desired number of pods."
252277
// +kubebuilder:printcolumn:name="CURRENT",type="integer",JSONPath=".status.replicas",description="The number of currently all pods."
278+
// +kubebuilder:printcolumn:name="AVAILABLE",type="integer",JSONPath=".status.availableReplicas",description="The number of pods available."
253279
// +kubebuilder:printcolumn:name="UPDATED",type="integer",JSONPath=".status.updatedReplicas",description="The number of pods updated."
254280
// +kubebuilder:printcolumn:name="UPDATED_READY",type="integer",JSONPath=".status.updatedReadyReplicas",description="The number of pods ready."
255281
// +kubebuilder:printcolumn:name="UPDATED_AVAILABLE",type="integer",JSONPath=".status.updatedAvailableReplicas",description="The number of pods updated available."

0 commit comments

Comments
 (0)