Skip to content

Commit fdd1199

Browse files
stuggiopenshift-cherrypick-robot
authored andcommitted
Remove unnecessary pods RBAC permissions
OpenStackClient's workload rbacRules granted full CRUD on core Pods to the ServiceAccount mounted into the OpenStackClient pod itself. That pod's entrypoint is a bare `sleep infinity` - any capability comes from what an admin runs interactively via exec, not from Kubernetes API access, so this grant is unnecessary and is removed entirely. The operator's own kubebuilder marker for pods on this same controller is untouched: it's independently justified by OpenStackClientReconciler directly creating/patching/deleting and watching (Owns(&corev1.Pod{})) that pod. Also narrow two dataplane controllers to their real usage: - OpenStackDataPlaneNodeSetReconciler only lists Pods (raw clientset, diagnostic listing of failed-deployment pods). Narrow its marker from full CRUD to list. - OpenStackDataPlaneDeploymentReconciler had no pods marker of its own at all, despite GetAnsibleExecutionSummary listing Pods via the cached client (needs list;watch for the informer) to build the ansible execution summary. It only worked by relying on the nodeset controller's now-narrowed marker via the ClusterRole merge - add its own list;watch marker so a future change to the nodeset controller can't silently break it. config/rbac/role.yaml is unchanged: OpenStackClient's own marker already grants full CRUD on pods for a real, direct need, so the merged ClusterRole doesn't shrink. The change is scoped to what gets delegated to workload ServiceAccounts and to per-controller marker correctness. Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent b200b5e commit fdd1199

3 files changed

Lines changed: 3 additions & 7 deletions

File tree

‎internal/controller/client/openstackclient_controller.go‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (r *OpenStackClientReconciler) GetLogger(ctx context.Context) logr.Logger {
8181
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update;patch
8282
// service account permissions that are needed to grant permission to the above
8383
// +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid,resources=securitycontextconstraints,verbs=use
84-
// +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch;patch
84+
// +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch
8585

8686
// Reconcile -
8787
func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) {
@@ -166,11 +166,6 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
166166
Resources: []string{"securitycontextconstraints"},
167167
Verbs: []string{"use"},
168168
},
169-
{
170-
APIGroups: []string{""},
171-
Resources: []string{"pods"},
172-
Verbs: []string{"create", "get", "list", "watch", "update", "patch", "delete"},
173-
},
174169
}
175170
rbacResult, err := common_rbac.ReconcileRbac(ctx, helper, instance, rbacRules)
176171
if err != nil {

‎internal/controller/dataplane/openstackdataplanedeployment_controller.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) GetLogger(ctx context.Context)
6464
// +kubebuilder:rbac:groups=dataplane.openstack.org,resources=openstackdataplanedeployments/finalizers,verbs=update;patch
6565
// +kubebuilder:rbac:groups=dataplane.openstack.org,resources=openstackdataplanenodesets,verbs=get;list;watch
6666
// +kubebuilder:rbac:groups=dataplane.openstack.org,resources=openstackdataplaneservices,verbs=get;list;watch
67+
// +kubebuilder:rbac:groups="",resources=pods,verbs=list;watch
6768
// +kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices,verbs=get;list;watch;create;update;patch;delete;
6869
// +kubebuilder:rbac:groups=cert-manager.io,resources=issuers,verbs=get;list;watch;
6970
// +kubebuilder:rbac:groups=cert-manager.io,resources=certificates,verbs=get;list;watch;create;update;patch;delete;

‎internal/controller/dataplane/openstackdataplanenodeset_controller.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) GetLogger(ctx context.Context) log
114114
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=get;list;watch;create;update;patch
115115
// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update;patch
116116
// +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid,resources=securitycontextconstraints,verbs=use
117-
// +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch
117+
// +kubebuilder:rbac:groups="",resources=pods,verbs=list
118118
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=get
119119
// +kubebuilder:rbac:groups="",resources=projects,verbs=get
120120
// +kubebuilder:rbac:groups="project.openshift.io",resources=projects,verbs=get

0 commit comments

Comments
 (0)