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

[4.15] OCPBUGS-31599: create suitable role and roleBinding for csi-snapshot-webhook #203

Merged
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
2 changes: 1 addition & 1 deletion assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"embed"
)

//go:embed *.yaml
//go:embed *.yaml rbac/*.yaml
var f embed.FS

// ReadFile reads and returns the content of the named file.
Expand Down
8 changes: 8 additions & 0 deletions assets/rbac/webhook_clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: csi-snapshot-webhook-clusterrole
rules:
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
12 changes: 12 additions & 0 deletions assets/rbac/webhook_clusterrolebinding.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: csi-snapshot-webhook-clusterrolebinding
subjects:
- kind: ServiceAccount
name: csi-snapshot-webhook
namespace: ${CONTROLPLANE_NAMESPACE}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: csi-snapshot-webhook-clusterrole
1 change: 1 addition & 0 deletions assets/webhook_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
labels:
app: csi-snapshot-webhook
spec:
serviceAccount: csi-snapshot-webhook
containers:
- name: webhook
image: ${OPERAND_IMAGE}
Expand Down
5 changes: 5 additions & 0 deletions assets/webhook_serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-snapshot-webhook
namespace: ${CONTROLPLANE_NAMESPACE}
7 changes: 7 additions & 0 deletions manifests/05_operator_clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,10 @@ rules:
- validatingwebhookconfigurations
verbs:
- "*"
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
- clusterrolebindings
verbs:
- "*"
3 changes: 3 additions & 0 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
"CSISnapshotGuestStaticResourceController",
namespacedAssetFunc,
[]string{
"rbac/webhook_clusterrole.yaml",
"rbac/webhook_clusterrolebinding.yaml",
"volumesnapshots.yaml",
"volumesnapshotcontents.yaml",
"volumesnapshotclasses.yaml",
Expand All @@ -148,6 +150,7 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
namespacedAssetFunc,
[]string{
"serviceaccount.yaml",
"webhook_serviceaccount.yaml",
"webhook_service.yaml",
},
resourceapply.NewKubeClientHolder(controlPlaneKubeClient),
Expand Down