Skip to content

Commit 7221be7

Browse files
stuggiopenshift-merge-bot[bot]
authored andcommitted
Remove unnecessary pods RBAC permissions
The workload rbacRules and kubebuilder RBAC markers granted the operator and its workload service account full CRUD (create/delete/get/list/patch/update/ watch) on core Pods, but the operator never reads or writes Pod objects directly — pods only ever come into being indirectly via Deployments/ StatefulSets/Jobs. Remove the unused pods permission and regenerate config/rbac/role.yaml. Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent 23ef43e commit 7221be7

3 files changed

Lines changed: 1 addition & 9 deletions

File tree

config/rbac/role.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ rules:
77
- apiGroups:
88
- ""
99
resources:
10-
- pods
1110
- secrets
1211
- services
1312
verbs:

internal/controller/watcher_controller.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ func (r *WatcherReconciler) GetLogger(ctx context.Context) logr.Logger {
8989
//+kubebuilder:rbac:groups=rabbitmq.openstack.org,resources=transporturls,verbs=get;list;watch;create;update;patch;delete
9090
//+kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneservices,verbs=get;list;watch;create;update;patch;delete;
9191
//+kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneendpoints,verbs=get;list;watch;create;update;patch;delete;
92-
//+kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch
9392
//+kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;patch;delete;
9493
// +kubebuilder:rbac:groups=batch,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete;
9594
//+kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=get;list;watch;create;update;patch;delete;
@@ -683,11 +682,6 @@ func (r *WatcherReconciler) ensureRbac(
683682
Resources: []string{"securitycontextconstraints"},
684683
Verbs: []string{"use"},
685684
},
686-
{
687-
APIGroups: []string{""},
688-
Resources: []string{"pods"},
689-
Verbs: []string{"create", "get", "list", "watch", "update", "patch", "delete"},
690-
},
691685
}
692686

693687
rbacResult, err := common_rbac.ReconcileRbac(ctx, h, instance, rbacRules)

test/functional/watcher_controller_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ var _ = Describe("Watcher controller", func() {
163163
corev1.ConditionTrue,
164164
)
165165
role := th.GetRole(watcherTest.RoleName)
166-
Expect(role.Rules).To(HaveLen(2))
166+
Expect(role.Rules).To(HaveLen(1))
167167
Expect(role.Rules[0].Resources).To(Equal([]string{"securitycontextconstraints"}))
168-
Expect(role.Rules[1].Resources).To(Equal([]string{"pods"}))
169168

170169
th.ExpectCondition(
171170
watcherTest.Instance,

0 commit comments

Comments
 (0)