Skip to content

Commit

Permalink
fix: kbcli set componentserviceaccontName (#4276)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuriwuyun committed Jul 14, 2023
1 parent c80ba1c commit 796f40d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
10 changes: 5 additions & 5 deletions controllers/apps/transformer_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ func (c *RBACTransformer) Transform(ctx graph.TransformContext, dag *graph.DAG)

for _, compSpec := range cluster.Spec.ComponentSpecs {
serviceAccountName := compSpec.ServiceAccountName
if serviceAccountName == "" {
return nil
}

if !viper.GetBool(constant.EnableRBACManager) {
transCtx.Logger.V(1).Info("rbac manager is not enabled")
if serviceAccountName != "" && !isServiceAccountExist(transCtx, serviceAccountName, true) {
if !isServiceAccountExist(transCtx, serviceAccountName, true) {
return ictrlutil.NewRequeueError(time.Second, serviceAccountName+" ServiceAccount is not exist")
}
return nil
}

if serviceAccountName == "" {
serviceAccountName = "kb-" + cluster.Name
}

if isRoleBindingExist(transCtx, serviceAccountName) {
continue
}
Expand Down
5 changes: 0 additions & 5 deletions internal/cli/cmd/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,6 @@ const (
// a service account, a role and a rolebinding
func (o *CreateOptions) buildDependenciesFn(cd *appsv1alpha1.ClusterDefinition,
compSpec *appsv1alpha1.ClusterComponentSpec) error {

if !o.RBACEnabled {
return nil
}

// set component service account name
compSpec.ServiceAccountName = saNamePrefix + o.Name
return nil
Expand Down

0 comments on commit 796f40d

Please sign in to comment.