Skip to content

Commit c7781dd

Browse files
authored
Merge pull request kubernetes-csi#156 from pohly/rbac
deploy: split out RBAC, fix leadership election permissions
2 parents a8d9d8d + 4940deb commit c7781dd

File tree

2 files changed

+92
-47
lines changed

2 files changed

+92
-47
lines changed

deploy/kubernetes/rbac.yaml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# This YAML file contains all RBAC objects that are necessary to run external
2+
# CSI provisioner.
3+
#
4+
# In production, each CSI driver deployment has to be customized:
5+
# - to avoid conflicts, use non-default namespace and different names
6+
# for non-namespaced entities like the ClusterRole
7+
# - decide whether the deployment replicates the external CSI
8+
# provisioner, in which case leadership election must be enabled;
9+
# this influences the RBAC setup, see below
10+
11+
apiVersion: v1
12+
kind: ServiceAccount
13+
metadata:
14+
name: csi-provisioner
15+
# replace with non-default namespace name
16+
namespace: default
17+
18+
---
19+
kind: ClusterRole
20+
apiVersion: rbac.authorization.k8s.io/v1
21+
metadata:
22+
name: external-provisioner-runner
23+
rules:
24+
- apiGroups: [""]
25+
resources: ["secrets"]
26+
verbs: ["get", "list"]
27+
- apiGroups: [""]
28+
resources: ["persistentvolumes"]
29+
verbs: ["get", "list", "watch", "create", "delete"]
30+
- apiGroups: [""]
31+
resources: ["persistentvolumeclaims"]
32+
verbs: ["get", "list", "watch", "update"]
33+
- apiGroups: ["storage.k8s.io"]
34+
resources: ["storageclasses"]
35+
verbs: ["get", "list", "watch"]
36+
- apiGroups: [""]
37+
resources: ["events"]
38+
verbs: ["list", "watch", "create", "update", "patch"]
39+
- apiGroups: ["snapshot.storage.k8s.io"]
40+
resources: ["volumesnapshots"]
41+
verbs: ["get", "list"]
42+
- apiGroups: ["snapshot.storage.k8s.io"]
43+
resources: ["volumesnapshotcontents"]
44+
verbs: ["get", "list"]
45+
46+
---
47+
kind: ClusterRoleBinding
48+
apiVersion: rbac.authorization.k8s.io/v1
49+
metadata:
50+
name: csi-provisioner-role
51+
subjects:
52+
- kind: ServiceAccount
53+
name: csi-provisioner
54+
# replace with non-default namespace name
55+
namespace: default
56+
roleRef:
57+
kind: ClusterRole
58+
name: external-provisioner-runner
59+
apiGroup: rbac.authorization.k8s.io
60+
61+
---
62+
# Provisioner must be able to work with endpoints in current namespace
63+
# if (and only if) leadership election is enabled
64+
kind: Role
65+
apiVersion: rbac.authorization.k8s.io/v1
66+
metadata:
67+
# replace with non-default namespace name
68+
namespace: default
69+
name: external-provisioner-cfg
70+
rules:
71+
- apiGroups: [""]
72+
resources: ["endpoints"]
73+
verbs: ["get", "watch", "list", "delete", "update", "create"]
74+
75+
---
76+
kind: RoleBinding
77+
apiVersion: rbac.authorization.k8s.io/v1
78+
metadata:
79+
name: csi-provisioner-role-cfg
80+
# replace with non-default namespace name
81+
namespace: default
82+
subjects:
83+
- kind: ServiceAccount
84+
name: csi-provisioner
85+
# replace with non-default namespace name
86+
namespace: default
87+
roleRef:
88+
kind: Role
89+
name: external-provisioner-cfg

deploy/kubernetes/statefulset.yaml

+3-47
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,6 @@
1-
# This YAML file contains all API objects that are necessary to run external
2-
# CSI provisioner.
3-
#
4-
# In production, this needs to be in separate files, e.g. service account and
5-
# role and role binding needs to be created once, while stateful set may
6-
# require some tuning.
7-
#
8-
# In addition, mock CSI driver is hardcoded as the CSI driver.
9-
10-
apiVersion: v1
11-
kind: ServiceAccount
12-
metadata:
13-
name: csi-provisioner
14-
15-
---
16-
kind: ClusterRole
17-
apiVersion: rbac.authorization.k8s.io/v1
18-
metadata:
19-
name: external-provisioner-runner
20-
rules:
21-
- apiGroups: [""]
22-
resources: ["persistentvolumes"]
23-
verbs: ["get", "list", "watch", "create", "delete"]
24-
- apiGroups: [""]
25-
resources: ["persistentvolumeclaims"]
26-
verbs: ["get", "list", "watch", "update"]
27-
- apiGroups: ["storage.k8s.io"]
28-
resources: ["storageclasses"]
29-
verbs: ["get", "list", "watch"]
30-
- apiGroups: [""]
31-
resources: ["events"]
32-
verbs: ["list", "watch", "create", "update", "patch"]
33-
34-
---
35-
kind: ClusterRoleBinding
36-
apiVersion: rbac.authorization.k8s.io/v1
37-
metadata:
38-
name: csi-provisioner-role
39-
subjects:
40-
- kind: ServiceAccount
41-
name: csi-provisioner
42-
namespace: default
43-
roleRef:
44-
kind: ClusterRole
45-
name: external-provisioner-runner
46-
apiGroup: rbac.authorization.k8s.io
1+
# This YAML file demonstrates how to deploy the external
2+
# provisioner for use with the mock CSI driver. It
3+
# depends on the RBAC definitions from rbac.yaml.
474

485
---
496
kind: Service
@@ -98,4 +55,3 @@ spec:
9855
volumes:
9956
- name: socket-dir
10057
emptyDir:
101-

0 commit comments

Comments
 (0)