Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STOR-1065: Rework sidecar bindings to bind common ClusterRoles #186

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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: manila-csi-driver-lease-leader-election
namespace: openshift-manila-csi-driver
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: manila-csi-driver-lease-leader-election
namespace: openshift-manila-csi-driver
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: manila-csi-driver-lease-leader-election
subjects:
- kind: ServiceAccount
name: manila-csi-driver-controller-sa
namespace: openshift-manila-csi-driver
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: manila-csi-provisioner-binding
name: manila-csi-main-provisioner-binding
subjects:
- kind: ServiceAccount
name: manila-csi-driver-controller-sa
namespace: openshift-manila-csi-driver
roleRef:
kind: ClusterRole
name: manila-external-provisioner-role
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incidentally, does something somewhere handle cleaning up the old roles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review, @mdbooth , appreciated!

This PR cleaned up old roles. E.g, it deleted assets/rbac/provisioner_role.yaml which published manila-external-provisioner-role. This role was specific for manila operator, so with this PR applied we don't have either manila-external-provisioner-role or corresponding binding.

name: openshift-csi-main-provisioner-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: manila-csi-snapshotter-binding
name: manila-csi-main-snapshotter-binding
subjects:
- kind: ServiceAccount
name: manila-csi-driver-controller-sa
namespace: openshift-manila-csi-driver
roleRef:
kind: ClusterRole
name: manila-external-snapshotter-role
name: openshift-csi-main-snapshotter-role
apiGroup: rbac.authorization.k8s.io
26 changes: 0 additions & 26 deletions assets/rbac/provisioner_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/volumeattachment_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: manila-csi-volumeattachment-reader-provisioner-binding
subjects:
- kind: ServiceAccount
name: manila-csi-driver-controller-sa
namespace: openshift-manila-csi-driver
roleRef:
kind: ClusterRole
name: openshift-csi-provisioner-volumeattachment-reader-role
apiGroup: rbac.authorization.k8s.io
9 changes: 5 additions & 4 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,18 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
// leading to an initial admission failure. We avoid
// this by exploiting the fact that the pods cannot be
// scheduled until the SA has been created.
"rbac/snapshotter_binding.yaml",
"rbac/snapshotter_role.yaml",
"rbac/provisioner_binding.yaml",
"rbac/provisioner_role.yaml",
"rbac/main_snapshotter_binding.yaml",
"rbac/main_provisioner_binding.yaml",
"rbac/volumeattachment_reader_provisioner_binding.yaml",
"rbac/privileged_role.yaml",
"rbac/controller_privileged_binding.yaml",
"rbac/node_privileged_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_sa.yaml",
"controller_pdb.yaml",
"node_sa.yaml",
Expand Down