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, azure-disk 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 Jun 28, 2023
1 parent e7c30d5 commit 9a3135a
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 116 deletions.
20 changes: 0 additions & 20 deletions assets/rbac/attacher_role.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions assets/rbac/lease_leader_election_role.yaml
@@ -0,0 +1,10 @@
# Role for electing leader by the operator
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: azure-disk-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
@@ -0,0 +1,14 @@
# Grant controller access to leases
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: azure-disk-csi-driver-lease-leader-election
namespace: openshift-cluster-csi-drivers
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: azure-disk-csi-driver-lease-leader-election
subjects:
- kind: ServiceAccount
name: azure-disk-csi-driver-controller-sa
namespace: openshift-cluster-csi-drivers
Expand Up @@ -8,5 +8,5 @@ subjects:
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: azure-disk-external-attacher-role
name: openshift-csi-main-attacher-role
apiGroup: rbac.authorization.k8s.io
Expand Up @@ -8,5 +8,5 @@ subjects:
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: azure-disk-external-provisioner-role
name: openshift-csi-main-provisioner-role
apiGroup: rbac.authorization.k8s.io
Expand Up @@ -8,5 +8,5 @@ subjects:
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: azure-disk-external-resizer-role
name: openshift-csi-main-resizer-role
apiGroup: rbac.authorization.k8s.io
Expand Up @@ -8,5 +8,5 @@ subjects:
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: azure-disk-external-snapshotter-role
name: openshift-csi-main-snapshotter-role
apiGroup: rbac.authorization.k8s.io
23 changes: 0 additions & 23 deletions assets/rbac/provisioner_role.yaml

This file was deleted.

23 changes: 0 additions & 23 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/storageclass_reader_resizer_binding.yaml
@@ -0,0 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: azure-disk-storageclass-reader-resizer-binding
subjects:
- kind: ServiceAccount
name: azure-disk-csi-driver-controller-sa
namespace: openshift-cluster-csi-drivers
roleRef:
kind: ClusterRole
name: openshift-csi-resizer-storageclass-reader-role
apiGroup: rbac.authorization.k8s.io
15 changes: 7 additions & 8 deletions pkg/operator/starter.go
Expand Up @@ -114,21 +114,20 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
kubeInformersForNamespaces,
assets.ReadFile,
[]string{
"rbac/attacher_role.yaml",
"rbac/attacher_binding.yaml",
"rbac/main_attacher_binding.yaml",
"rbac/privileged_role.yaml",
"rbac/controller_privileged_binding.yaml",
"rbac/node_privileged_binding.yaml",
"rbac/provisioner_role.yaml",
"rbac/provisioner_binding.yaml",
"rbac/resizer_role.yaml",
"rbac/resizer_binding.yaml",
"rbac/snapshotter_role.yaml",
"rbac/snapshotter_binding.yaml",
"rbac/main_provisioner_binding.yaml",
"rbac/main_resizer_binding.yaml",
"rbac/storageclass_reader_resizer_binding.yaml",
"rbac/main_snapshotter_binding.yaml",
"rbac/kube_rbac_proxy_role.yaml",
"rbac/kube_rbac_proxy_binding.yaml",
"rbac/prometheus_role.yaml",
"rbac/prometheus_rolebinding.yaml",
"rbac/lease_leader_election_role.yaml",
"rbac/lease_leader_election_rolebinding.yaml",
"controller_pdb.yaml",
"csidriver.yaml",
"service.yaml",
Expand Down

0 comments on commit 9a3135a

Please sign in to comment.