Skip to content

Commit d5acf2c

Browse files
cjc7373apecloud-bot
authored andcommitted
chore: a new serviceaccount naming policy (#10029)
(cherry picked from commit b893218)
1 parent caa26fa commit d5acf2c

35 files changed

Lines changed: 636 additions & 150 deletions

apis/apps/v1/cluster_types.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,14 @@ type ClusterComponentSpec struct {
434434
// with other Kubernetes resources, such as modifying Pod labels or sending events.
435435
//
436436
// If not specified, KubeBlocks automatically creates a default ServiceAccount named
437-
// "kb-{componentdefinition.name}", bound to a role with rules defined in ComponentDefinition's
437+
// "kb-{clusterName}-{compName}", bound to a cluster role with rules defined in ComponentDefinition's
438438
// `policyRules` field. If needed (currently this means if any lifecycleAction is enabled),
439-
// it will also be bound to a default role named
439+
// it will also be bound to a default cluster role named
440440
// "kubeblocks-cluster-pod-role", which is installed together with KubeBlocks.
441-
// If multiple components use the same ComponentDefinition, they will share one ServiceAccount.
441+
//
442+
// Before KubeBlocks 1.1, the automatically created serviceaccount is named "kb-{componentdefinition.name}".
443+
// To reduce unintended pod restart, old pods still use old serviceaccount. New serviceaccount will be used
444+
// when a workload has been restarted.
442445
//
443446
// If the field is not empty, the specified ServiceAccount will be used, and KubeBlocks will not
444447
// create a ServiceAccount. But KubeBlocks does create RoleBindings for the specified ServiceAccount.

apis/apps/v1/component_types.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,14 @@ type ComponentSpec struct {
197197
// with other Kubernetes resources, such as modifying Pod labels or sending events.
198198
//
199199
// If not specified, KubeBlocks automatically creates a default ServiceAccount named
200-
// "kb-{componentdefinition.name}", bound to a role with rules defined in ComponentDefinition's
200+
// "kb-{clusterName}-{compName}", bound to a cluster role with rules defined in ComponentDefinition's
201201
// `policyRules` field. If needed (currently this means if any lifecycleAction is enabled),
202-
// it will also be bound to a default role named
202+
// it will also be bound to a default cluster role named
203203
// "kubeblocks-cluster-pod-role", which is installed together with KubeBlocks.
204-
// If multiple components use the same ComponentDefinition, they will share one ServiceAccount.
204+
//
205+
// Before KubeBlocks 1.1, the automatically created serviceaccount is named "kb-{componentdefinition.name}".
206+
// To reduce unintended pod restart, old pods still use old serviceaccount. New serviceaccount will be used
207+
// when a workload has been restarted.
205208
//
206209
// If the field is not empty, the specified ServiceAccount will be used, and KubeBlocks will not
207210
// create a ServiceAccount. But KubeBlocks does create RoleBindings for the specified ServiceAccount.

apis/workloads/v1/instanceset_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ type InstanceSetStatus struct {
352352
// +optional
353353
UpdateRevisions map[string]string `json:"updateRevisions,omitempty"`
354354

355+
// revisions of desired pod template. But the update process is deferred until another pod update process is triggered.
356+
// i.e. a running pod may still use a revision in `updateRevisions`.
357+
// key is the pod name, value is the revision.
358+
//
359+
// +optional
360+
DeferredUpdatedRevisions map[string]string `json:"deferredUpdatedRevisions,omitempty"`
361+
355362
// TemplatesStatus represents status of each instance generated by InstanceTemplates.
356363
//
357364
// +optional

apis/workloads/v1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4156,11 +4156,15 @@ spec:
41564156

41574157

41584158
If not specified, KubeBlocks automatically creates a default ServiceAccount named
4159-
"kb-{componentdefinition.name}", bound to a role with rules defined in ComponentDefinition's
4159+
"kb-{clusterName}-{compName}", bound to a cluster role with rules defined in ComponentDefinition's
41604160
`policyRules` field. If needed (currently this means if any lifecycleAction is enabled),
4161-
it will also be bound to a default role named
4161+
it will also be bound to a default cluster role named
41624162
"kubeblocks-cluster-pod-role", which is installed together with KubeBlocks.
4163-
If multiple components use the same ComponentDefinition, they will share one ServiceAccount.
4163+
4164+
4165+
Before KubeBlocks 1.1, the automatically created serviceaccount is named "kb-{componentdefinition.name}".
4166+
To reduce unintended pod restart, old pods still use old serviceaccount. New serviceaccount will be used
4167+
when a workload has been restarted.
41644168

41654169

41664170
If the field is not empty, the specified ServiceAccount will be used, and KubeBlocks will not
@@ -15527,11 +15531,15 @@ spec:
1552715531

1552815532

1552915533
If not specified, KubeBlocks automatically creates a default ServiceAccount named
15530-
"kb-{componentdefinition.name}", bound to a role with rules defined in ComponentDefinition's
15534+
"kb-{clusterName}-{compName}", bound to a cluster role with rules defined in ComponentDefinition's
1553115535
`policyRules` field. If needed (currently this means if any lifecycleAction is enabled),
15532-
it will also be bound to a default role named
15536+
it will also be bound to a default cluster role named
1553315537
"kubeblocks-cluster-pod-role", which is installed together with KubeBlocks.
15534-
If multiple components use the same ComponentDefinition, they will share one ServiceAccount.
15538+
15539+
15540+
Before KubeBlocks 1.1, the automatically created serviceaccount is named "kb-{componentdefinition.name}".
15541+
To reduce unintended pod restart, old pods still use old serviceaccount. New serviceaccount will be used
15542+
when a workload has been restarted.
1553515543

1553615544

1553715545
If the field is not empty, the specified ServiceAccount will be used, and KubeBlocks will not

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4382,11 +4382,15 @@ spec:
43824382

43834383

43844384
If not specified, KubeBlocks automatically creates a default ServiceAccount named
4385-
"kb-{componentdefinition.name}", bound to a role with rules defined in ComponentDefinition's
4385+
"kb-{clusterName}-{compName}", bound to a cluster role with rules defined in ComponentDefinition's
43864386
`policyRules` field. If needed (currently this means if any lifecycleAction is enabled),
4387-
it will also be bound to a default role named
4387+
it will also be bound to a default cluster role named
43884388
"kubeblocks-cluster-pod-role", which is installed together with KubeBlocks.
4389-
If multiple components use the same ComponentDefinition, they will share one ServiceAccount.
4389+
4390+
4391+
Before KubeBlocks 1.1, the automatically created serviceaccount is named "kb-{componentdefinition.name}".
4392+
To reduce unintended pod restart, old pods still use old serviceaccount. New serviceaccount will be used
4393+
when a workload has been restarted.
43904394

43914395

43924396
If the field is not empty, the specified ServiceAccount will be used, and KubeBlocks will not

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11743,6 +11743,14 @@ spec:
1174311743
currentRevisions, if not empty, indicates the old version of the InstanceSet used to generate the underlying workload.
1174411744
key is the pod name, value is the revision.
1174511745
type: object
11746+
deferredUpdatedRevisions:
11747+
additionalProperties:
11748+
type: string
11749+
description: |-
11750+
revisions of desired pod template. But the update process is deferred until another pod update process is triggered.
11751+
i.e. a running pod may still use a revision in `updateRevisions`.
11752+
key is the pod name, value is the revision.
11753+
type: object
1174611754
initReplicas:
1174711755
description: |-
1174811756
Defines the initial number of instances when the cluster is first initialized.

0 commit comments

Comments
 (0)