Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
kind: ClusterRole
metadata:
creationTimestamp: null
name: netobserv-config-watcher
Expand Down
2 changes: 1 addition & 1 deletion config/rbac/component_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ rules:
- create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
kind: ClusterRole
metadata:
name: config-watcher
rules:
Expand Down
2 changes: 1 addition & 1 deletion controllers/flp/flp_monolith_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (r *monolithReconciler) reconcilePermissions(ctx context.Context, builder *
}

// Config watcher
r.rbConfigWatcher = resources.GetRoleBinding(r.Namespace, monoShortName, monoName, monoName, constants.ConfigWatcherRole)
r.rbConfigWatcher = resources.GetRoleBinding(r.Namespace, monoShortName, monoName, monoName, constants.ConfigWatcherRole, true)
if err := r.ReconcileRoleBinding(ctx, r.rbConfigWatcher); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/flp/flp_transfo_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (r *transformerReconciler) reconcilePermissions(ctx context.Context, builde
}

// Config watcher
r.rbConfigWatcher = resources.GetRoleBinding(r.Namespace, transfoShortName, transfoName, transfoName, constants.ConfigWatcherRole)
r.rbConfigWatcher = resources.GetRoleBinding(r.Namespace, transfoShortName, transfoName, transfoName, constants.ConfigWatcherRole, true)
if err := r.ReconcileRoleBinding(ctx, r.rbConfigWatcher); err != nil {
return err
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/resources/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ func GetClusterRoleBindingName(shortName string, ref constants.ClusterRoleName)
return string(ref) + "-" + shortName
}

func GetRoleBinding(namespace, shortName, app, sa string, ref constants.RoleName) *rbacv1.RoleBinding {
func GetRoleBinding(namespace, shortName, app, sa string, ref constants.RoleName, fromClusterRole bool) *rbacv1.RoleBinding {
roleKind := "Role"
if fromClusterRole {
roleKind = "ClusterRole"
}
return &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: string(ref) + "-" + shortName,
Expand All @@ -23,7 +27,7 @@ func GetRoleBinding(namespace, shortName, app, sa string, ref constants.RoleName
},
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "Role",
Kind: roleKind,
Name: string(ref),
},
Subjects: []rbacv1.Subject{{
Expand Down