Skip to content

Commit

Permalink
Merge pull request #207 from openshift-cherrypick-robot/cherry-pick-2…
Browse files Browse the repository at this point in the history
…06-to-release-4.12

[release-4.12] OCPBUGS-32429: create suitable role and roleBinding for csi-snapshot-webhook
  • Loading branch information
openshift-merge-bot[bot] committed Apr 19, 2024
2 parents afc1c5d + cf053d7 commit f573ede
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
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 @@ -131,6 +131,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 @@ -145,6 +147,7 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
namespacedAssetFunc,
[]string{
"serviceaccount.yaml",
"webhook_serviceaccount.yaml",
"webhook_service.yaml",
},
resourceapply.NewKubeClientHolder(controlPlaneKubeClient),
Expand Down

0 comments on commit f573ede

Please sign in to comment.