Skip to content

Commit

Permalink
STOR-1065: Rework sidecar bindings to bind common ClusterRoles
Browse files Browse the repository at this point in the history
PR openshift/cluster-storage-operator#379 published builiding blocks of sidecar ClusterRoles. Now, ibm-vpc-block csi driver operator may compose its sidecars ClusterRoles from those building blocks.

This PR also moves permissions for `leases` resource from ClusterRole to per-namespace Role (`assets/rbac/lease_leader_election_role.yaml`).
  • Loading branch information
mpatlasov committed Jul 3, 2023
1 parent ca8a20b commit ff36f2e
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 215 deletions.
47 changes: 0 additions & 47 deletions assets/rbac/attacher_role.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions assets/rbac/configmap_and_secret_reader_provisioner_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: ibm-vpc-block-csi-configmap-and-secret-reader-provisioner-binding
subjects:
- kind: ServiceAccount
name: ibm-vpc-block-controller-sa
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: openshift-csi-provisioner-configmap-and-secret-reader-role
apiGroup: rbac.authorization.k8s.io
10 changes: 10 additions & 0 deletions assets/rbac/lease_leader_election_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Role for electing leader by the operator
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: ibm-vpc-block-csi-driver-lease-leader-election
namespace: openshift-cluster-csi-drivers
rules:
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "watch", "list", "delete", "update", "create"]
14 changes: 14 additions & 0 deletions assets/rbac/lease_leader_election_rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Grant controller access to leases
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: ibm-vpc-block-csi-driver-lease-leader-election
namespace: openshift-cluster-csi-drivers
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: ibm-vpc-block-csi-driver-lease-leader-election
subjects:
- kind: ServiceAccount
name: ibm-vpc-block-controller-sa
namespace: openshift-cluster-csi-drivers
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: ibm-vpc-block-csi-driver
name: vpc-block-provisioner-binding
name: vpc-block-main-attacher-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: vpc-block-provisioner-role
name: openshift-csi-main-attacher-role
subjects:
- kind: ServiceAccount
name: ibm-vpc-block-controller-sa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
app: ibm-vpc-block-csi-driver
name: vpc-block-external-attacher-binding
name: vpc-block-main-provisioner-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: vpc-block-external-attacher-role
name: openshift-csi-main-provisioner-role
subjects:
- kind: ServiceAccount
name: ibm-vpc-block-controller-sa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: vpc-block-external-resizer-binding
name: vpc-block-main-resizer-binding
labels:
app: ibm-vpc-block-csi-driver
addonmanager.kubernetes.io/mode: Reconcile
Expand All @@ -12,5 +12,5 @@
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: vpc-block-external-resizer-role
name: openshift-csi-main-resizer-role
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: vpc-block-driver-snapshotter-binding
name: vpc-block-main-snapshotter-binding
subjects:
- kind: ServiceAccount
name: ibm-vpc-block-controller-sa
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: vpc-block-driver-snapshotter-role
name: openshift-csi-main-snapshotter-role
apiGroup: rbac.authorization.k8s.io
90 changes: 0 additions & 90 deletions assets/rbac/provisioner_role.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions assets/rbac/resizer_role.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions assets/rbac/snapshotter_role.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions assets/rbac/volumesnapshot_reader_provisioner_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: ibm-vpc-block-csi-volumesnapshot-reader-provisioner-binding
subjects:
- kind: ServiceAccount
name: ibm-vpc-block-controller-sa
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: openshift-csi-provisioner-volumesnapshot-reader-role
apiGroup: rbac.authorization.k8s.io
16 changes: 8 additions & 8 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
"csidriver.yaml",
"node_sa.yaml",
"cabundle_cm.yaml",
"rbac/attacher_role.yaml",
"rbac/attacher_rolebinding.yaml",
"rbac/provisioner_binding.yaml",
"rbac/provisioner_role.yaml",
"rbac/main_attacher_binding.yaml",
"rbac/main_provisioner_binding.yaml",
"rbac/volumesnapshot_reader_provisioner_binding.yaml",
"rbac/configmap_and_secret_reader_provisioner_binding.yaml",
"rbac/node_privileged_binding.yaml",
"rbac/privileged_role.yaml",
"rbac/node_label_updater_binding.yaml",
"rbac/label_updater_role.yaml",
"rbac/resizer_role.yaml",
"rbac/resizer_rolebinding.yaml",
"rbac/main_resizer_binding.yaml",
"rbac/initcontainer_role.yaml",
"rbac/initcontainer_rolebinding.yaml",
"rbac/snapshotter_binding.yaml",
"rbac/snapshotter_role.yaml",
"rbac/main_snapshotter_binding.yaml",
"rbac/lease_leader_election_role.yaml",
"rbac/lease_leader_election_rolebinding.yaml",
},
).WithConditionalStaticResourcesController(
"IBMBlockDriverConditionalStaticResourcesController",
Expand Down

0 comments on commit ff36f2e

Please sign in to comment.