Skip to content

Commit 1ff87c4

Browse files
committed
refactor naming policy api
1 parent d8b5a37 commit 1ff87c4

3 files changed

Lines changed: 42 additions & 13 deletions

File tree

apps/v1alpha1/collaset_types.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ const (
2828
CollaSetUpdate CollaSetConditionType = "Update"
2929
)
3030

31-
// PodNamingPolicy is a string enumeration that determaines how pod name will be generated.
31+
// ReplicaNamingPolicy is a string enumeration that determaines how pod name will be generated.
3232
// A collaset pod name contains two parts to be placed in a string formation %s-%s; the prefix
33-
// is name of collaset, and the suffix is determined by PodNamingPolicy.
34-
type PodNamingPolicy string
33+
// is name of collaset, and the suffix is determined by ReplicaNamingPolicy.
34+
type ReplicaNamingPolicy string
3535

3636
const (
37-
// PodNamingPolicyPersistentSequence uses persistent sequential numbers as pod name suffix.
38-
PodNamingPolicyPersistentSequence PodNamingPolicy = "PersistentSequence"
39-
// PodNamingPolicyDefault uses random strings which are provided by Kubernetes as pod name suffix.
37+
// ReplicaNamingPolicyPersistentSequence uses persistent sequential numbers as pod name suffix.
38+
ReplicaNamingPolicyPersistentSequence ReplicaNamingPolicy = "PersistentSequence"
39+
// ReplicaNamingPolicyDefault uses random strings which are provided by Kubernetes as pod name suffix.
4040
// This is defaulting value.
41-
PodNamingPolicyDefault PodNamingPolicy = "Default"
41+
ReplicaNamingPolicyDefault ReplicaNamingPolicy = "Default"
4242
)
4343

4444
// PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine
@@ -120,6 +120,10 @@ type CollaSetSpec struct {
120120
// +optional
121121
ScaleStrategy ScaleStrategy `json:"scaleStrategy,omitempty"`
122122

123+
// NamigPolicy indicates the strategy detail that will be used for replica naming
124+
// +optional
125+
NamingPolicy NamingPolicy `json:"namimgPolicy,omitempty"`
126+
123127
// Indicate the number of histories to be conserved
124128
// If unspecified, defaults to 20
125129
// +optional
@@ -133,9 +137,6 @@ type ScaleStrategy struct {
133137
// +optional
134138
Context string `json:"context,omitempty"`
135139

136-
// PodNamingPolicy indicates how a new pod name is generated.
137-
PodNamingPolicy PodNamingPolicy `json:"podNamingPolicy,omitempty"`
138-
139140
// PodToExclude indicates the pods which will be orphaned by CollaSet.
140141
// +optional
141142
PodToExclude []string `json:"podToExclude,omitempty"`
@@ -160,6 +161,11 @@ type ScaleStrategy struct {
160161
OperationDelaySeconds *int32 `json:"operationDelaySeconds,omitempty"`
161162
}
162163

164+
type NamingPolicy struct {
165+
// ReplicaNamingPolicy indicates how a new pod name is generated.
166+
ReplicaNamingPolicy ReplicaNamingPolicy `json:"replicaNamingPolicy,omitempty"`
167+
}
168+
163169
type PersistentVolumeClaimRetentionPolicy struct {
164170
// WhenDeleted specifies what happens to PVCs created from CollaSet
165171
// VolumeClaimTemplates when the CollaSet is deleted. The default policy

apps/v1alpha1/zz_generated.deepcopy.go

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

config/crd/apps/apps.kusionstack.io_collasets.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ spec:
8383
If unspecified, defaults to 20
8484
format: int32
8585
type: integer
86+
namimgPolicy:
87+
description: NamigPolicy indicates the strategy detail that will be
88+
used for replica naming
89+
properties:
90+
replicaNamingPolicy:
91+
description: ReplicaNamingPolicy indicates how a new pod name
92+
is generated.
93+
type: string
94+
type: object
8695
paused:
8796
description: |-
8897
Indicates that the scaling and updating is paused and will not be processed by the
@@ -134,9 +143,6 @@ spec:
134143
the replica count to be deleted.
135144
type: string
136145
type: object
137-
podNamingPolicy:
138-
description: PodNamingPolicy indicates how a new pod name is generated.
139-
type: string
140146
podToDelete:
141147
description: PodToDelete indicates the pods which will be deleted
142148
by CollaSet.

0 commit comments

Comments
 (0)