Skip to content

Commit 252b867

Browse files
committed
Remove unnecessary pods RBAC permissions
The workload rbacRules and the matching kubebuilder RBAC marker in the controller granted the workload service account full CRUD (create/delete/get/list/patch/update/watch) on core Pods, but that service account never reads or writes Pod objects directly. Remove the unused grants. The kubebuilder RBAC marker for pods (get;list) is kept: lib-common's VerifyNetworkStatusFromAnnotation, called from this controller to verify NetworkAttachments, lists Pods using the controller-manager's own client, so the manager's ClusterRole (config/rbac/role.yaml) still needs get;list on pods. Regenerate config/rbac/role.yaml. Includes ef1e3b5 Signed-off-by: Martin Schuppert <mschuppert@redhat.com> (cherry picked from commit 2adbb94)
1 parent 0315d93 commit 252b867

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

config/rbac/role.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ rules:
88
- ""
99
resources:
1010
- configmaps
11-
- pods
1211
- secrets
1312
- services
1413
verbs:
@@ -26,6 +25,13 @@ rules:
2625
verbs:
2726
- create
2827
- patch
28+
- apiGroups:
29+
- ""
30+
resources:
31+
- pods
32+
verbs:
33+
- get
34+
- list
2935
- apiGroups:
3036
- ""
3137
resources:

internal/controller/keystoneapi_controller.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ type KeystoneAPIReconciler struct {
125125
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update;patch
126126
// keystone service account permissions that are needed to grant permission to the above
127127
// +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid,resources=securitycontextconstraints,verbs=use
128-
// +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch
128+
// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list
129129

130130
// Reconcile reconcile keystone API requests
131131
func (r *KeystoneAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) {
@@ -549,11 +549,6 @@ func (r *KeystoneAPIReconciler) reconcileInit(
549549
Resources: []string{"securitycontextconstraints"},
550550
Verbs: []string{"use"},
551551
},
552-
{
553-
APIGroups: []string{""},
554-
Resources: []string{"pods"},
555-
Verbs: []string{"create", "get", "list", "watch", "update", "patch", "delete"},
556-
},
557552
}
558553
rbacResult, err := common_rbac.ReconcileRbac(ctx, helper, instance, rbacRules)
559554
if err != nil {

0 commit comments

Comments
 (0)