Skip to content

Commit db21674

Browse files
authored
Merge pull request #710 from shawn-hurley/backport=706
Backport-706 Adding webhook RBAC to enable validation of snapshotclasses
2 parents 70540ec + 4805533 commit db21674

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

deploy/kubernetes/webhook-example/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ These commands should be run from the top level directory.
5656

5757
3. Change the namespace in the generated `admission-configuration.yaml` file. Change the namespace in the service and deployment in the `webhook.yaml` file.
5858

59-
4. Create the deployment, service and admission configuration objects on the cluster.
59+
4. Create the deployment, service, RBAC, and admission configuration objects on the cluster.
6060

6161
```bash
6262
kubectl apply -f ./deploy/kubernetes/webhook-example
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# RBAC file for the snapshot webhook.
2+
#
3+
# The snapshot webhook implements the validation and admission for CSI snapshot functionality.
4+
# It should be installed as part of the base Kubernetes distribution in an appropriate
5+
# namespace for components implementing base system functionality. For installing with
6+
# Vanilla Kubernetes, kube-system makes sense for the namespace.
7+
8+
apiVersion: v1
9+
kind: ServiceAccount
10+
metadata:
11+
name: snapshot-webhook
12+
namespace: default # NOTE: change the namespace
13+
---
14+
kind: ClusterRole
15+
apiVersion: rbac.authorization.k8s.io/v1
16+
metadata:
17+
name: snapshot-webhook-runner
18+
rules:
19+
- apiGroups: ["snapshot.storage.k8s.io"]
20+
resources: ["volumesnapshotclasses"]
21+
verbs: ["get", "list", "watch"]
22+
---
23+
kind: ClusterRoleBinding
24+
apiVersion: rbac.authorization.k8s.io/v1
25+
metadata:
26+
name: snapshot-webhook-role
27+
subjects:
28+
- kind: ServiceAccount
29+
name: snapshot-webhook
30+
namespace: default # NOTE: change the namespace
31+
roleRef:
32+
kind: ClusterRole
33+
name: snapshot-webhook-runner
34+
apiGroup: rbac.authorization.k8s.io

deploy/kubernetes/webhook-example/webhook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ spec:
1515
labels:
1616
app: snapshot-validation
1717
spec:
18+
serviceAccountName: snapshot-webhook
1819
containers:
1920
- name: snapshot-validation
2021
image: k8s.gcr.io/sig-storage/snapshot-validation-webhook:v5.0.1 # change the image if you wish to use your own custom validation server image

0 commit comments

Comments
 (0)