Skip to content

Commit 734955a

Browse files
authored
Merge pull request #42 from appuio/fix/namespace-owner-reference
Fix permission to be able to set owner references
2 parents 7bbf1ac + bb3d7d2 commit 734955a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

config/rbac/role.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ rules:
2020
- get
2121
- list
2222
- watch
23+
- apiGroups:
24+
- ""
25+
resources:
26+
- namespaces/finalizers
27+
verbs:
28+
- update
2329
- apiGroups:
2430
- ""
2531
resources:

controllers/org_rbac_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const LabelRoleBindingUninitialized = "appuio.io/uninitialized"
3737
//+kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;patch;update
3838
//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch
3939

40+
// We don't actually want or need to set finalizers, but if "OwnerReferencesPermissionEnforcement" is enabled we need this permission to set an owner reference to a namespace
41+
//+kubebuilder:rbac:groups="",resources=namespaces/finalizers,verbs=update
42+
4043
// Reconcile makes sure the role bindings for the configured cluster roles are present in every organization namespace.
4144
// It will also update role bindings with the label "appuio.io/uninitialized": "true" to the default config.
4245
func (r *OrganizationRBACReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
@@ -100,8 +103,7 @@ func (r *OrganizationRBACReconciler) putRoleBinding(ctx context.Context, ns core
100103
}
101104
delete(rb.Labels, LabelRoleBindingUninitialized)
102105
}
103-
controllerutil.SetControllerReference(&ns, rb, r.Scheme)
104-
return nil
106+
return controllerutil.SetControllerReference(&ns, rb, r.Scheme)
105107
})
106108

107109
return err

0 commit comments

Comments
 (0)