Skip to content

Commit 496f60e

Browse files
collaset api: add NamingStrategy in spec (#43)
* collaset api: add PodNamingPolicy in scaleStrategy * remove unused ci * remove unused ci * remove unused ci * refactor suffix * refactor naming policy api * refactor naming policy api * refactor naming policy api * refactor naming policy api * refactor naming policy api * refactor naming policy api * refactor naming policy api
1 parent 11fa6b6 commit 496f60e

File tree

4 files changed

+56
-8
lines changed

4 files changed

+56
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,4 @@ jobs:
7070
- name: Checkout
7171
uses: actions/checkout@v3
7272
with:
73-
fetch-depth: 0
74-
- name: TruffleHog OSS
75-
uses: trufflesecurity/trufflehog@main
76-
with:
77-
path: ./
78-
base: ${{ github.event.repository.default_branch }}
79-
head: HEAD
80-
extra_args: --debug --json
73+
fetch-depth: 0

apps/v1alpha1/collaset_types.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ const (
2828
CollaSetUpdate CollaSetConditionType = "Update"
2929
)
3030

31+
// PodNamingSuffixPolicy indicates how a new pod name suffix part is generated.
32+
type PodNamingSuffixPolicy string
33+
34+
const (
35+
// PodNamingSuffixPolicyPersistentSequence uses persistent sequential numbers as pod name suffix.
36+
PodNamingSuffixPolicyPersistentSequence PodNamingSuffixPolicy = "PersistentSequence"
37+
// PodNamingSuffixPolicyRandom uses collaset name as pod generateName, which is the prefix
38+
// of pod name. Kubernetes then adds a random string as suffix after the generateName.
39+
// This is defaulting policy.
40+
PodNamingSuffixPolicyRandom PodNamingSuffixPolicy = "Random"
41+
)
42+
3143
// PersistentVolumeClaimRetentionPolicyType is a string enumeration of the policies that will determine
3244
// which action will be applied on volumes from the VolumeClaimTemplates when the CollaSet is
3345
// deleted or scaled down.
@@ -107,6 +119,10 @@ type CollaSetSpec struct {
107119
// +optional
108120
ScaleStrategy ScaleStrategy `json:"scaleStrategy,omitempty"`
109121

122+
// NamigPolicy indicates the strategy detail that will be used for replica naming
123+
// +optional
124+
NamingStrategy *NamingStrategy `json:"namingStrategy,omitempty"`
125+
110126
// Indicate the number of histories to be conserved
111127
// If unspecified, defaults to 20
112128
// +optional
@@ -144,6 +160,13 @@ type ScaleStrategy struct {
144160
OperationDelaySeconds *int32 `json:"operationDelaySeconds,omitempty"`
145161
}
146162

163+
type NamingStrategy struct {
164+
// PodNamingSuffixPolicy is a string enumeration that determaines how pod name suffix will be generated.
165+
// A collaset pod name contains two parts to be placed in a string formation %s-%s; the prefix is collaset
166+
// name, and the suffix is determined by PodNamingSuffixPolicy.
167+
PodNamingSuffixPolicy PodNamingSuffixPolicy `json:"podNamingSuffixPolicy,omitempty"`
168+
}
169+
147170
type PersistentVolumeClaimRetentionPolicy struct {
148171
// WhenDeleted specifies what happens to PVCs created from CollaSet
149172
// VolumeClaimTemplates when the CollaSet is deleted. The default policy

apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ spec:
8383
If unspecified, defaults to 20
8484
format: int32
8585
type: integer
86+
namingStrategy:
87+
description: NamigPolicy indicates the strategy detail that will be
88+
used for replica naming
89+
properties:
90+
podNamingSuffixPolicy:
91+
description: |-
92+
PodNamingSuffixPolicy is a string enumeration that determaines how pod name suffix will be generated.
93+
A collaset pod name contains two parts to be placed in a string formation %s-%s; the prefix is collaset
94+
name, and the suffix is determined by PodNamingSuffixPolicy.
95+
type: string
96+
type: object
8697
paused:
8798
description: |-
8899
Indicates that the scaling and updating is paused and will not be processed by the

0 commit comments

Comments
 (0)