Skip to content

Commit c68d839

Browse files
committed
operator: Include ClusterRole permission for redpanda controller
In the redpanda package the kubebuilder comment does not have all possible variants of ClusterRole permissions neccessery to handle creation of all Redpanda helm chart resources. During integration test suite execution controller runtime complain about leases permissions missing. ``` error: deploying *v1.Role: \"rp-4bpw0i-sidecar-controllers\": roles.rbac.authorization.k8s.io \"rp-4bpw0i-sidecar-controllers\" is forbidden: user \"system:serviceaccount:testenv-wm758:testenv-pzy3ce\" (groups=[\"system:serviceaccounts\" \"system:serviceaccounts:testenv-wm758\" \"system:authenticated\"]) is attempting to grant RBAC permissions not currently held: {APIGroups:[\"coordination.k8s.io\"], Resources:[\"leases\"], Verbs:[\"create\" \"delete\" \"get\" \"list\" \"patch\" \"update\" \"watch\"]}" ``` The setup of integration test suite included only permissions defined in redpanda package. Kustomize and Operator helm chart includes those missing permissions.
1 parent 92c19f4 commit c68d839

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

operator/config/rbac/v2-manager-role/role.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ rules:
187187
- patch
188188
- update
189189
- watch
190+
- apiGroups:
191+
- coordination.k8s.io
192+
resources:
193+
- leases
194+
verbs:
195+
- create
196+
- delete
197+
- get
198+
- list
199+
- patch
200+
- update
201+
- watch
190202
- apiGroups:
191203
- monitoring.coreos.com
192204
resources:

operator/internal/controller/redpanda/redpanda_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ type RedpandaReconciler struct {
9797
// +kubebuilder:rbac:groups=cluster.redpanda.com,resources=redpandas/finalizers,verbs=update
9898
// +kubebuilder:rbac:groups=core,namespace=default,resources=events,verbs=create;patch
9999

100+
// sidecar resources
101+
// The leases is used by controller-runtime in sidecar. Operator main reconciliation needs to have leases permissions in order to create role that have the same permissions.
102+
// +kubebuilder:rbac:groups=coordination.k8s.io,namespace=default,resources=leases,verbs=get;list;watch;create;update;patch;delete
103+
100104
// SetupWithManager sets up the controller with the Manager.
101105
func (r *RedpandaReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
102106
if err := registerHelmReferencedIndex(ctx, mgr, "statefulset", &appsv1.StatefulSet{}); err != nil {

operator/internal/controller/redpanda/role.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ rules:
187187
- patch
188188
- update
189189
- watch
190+
- apiGroups:
191+
- coordination.k8s.io
192+
resources:
193+
- leases
194+
verbs:
195+
- create
196+
- delete
197+
- get
198+
- list
199+
- patch
200+
- update
201+
- watch
190202
- apiGroups:
191203
- monitoring.coreos.com
192204
resources:

0 commit comments

Comments
 (0)