Skip to content

Commit 0344817

Browse files
authored
Merge pull request #247 from adambkaplan/fix-rbac-readme
BUILD-1168: Remove Operator-owned RBAC
2 parents eddac1b + ab3a975 commit 0344817

File tree

1 file changed

+47
-46
lines changed

1 file changed

+47
-46
lines changed

README.md

+47-46
Original file line numberDiff line numberDiff line change
@@ -41,97 +41,98 @@ Sharing resources is done as follows:
4141
kind: ConfigMap
4242
metadata:
4343
name: shared-config
44-
namespace: default # This can be any desired "source" namespace
44+
namespace: test-share-source # This can be any desired "source" namespace
4545
data:
4646
config.txt: "Hello world!"
4747
```
4848
49-
2. The resource owner should create a corresponding `SharedSecret` or `SharedConfigMap` instance to make the resource shareable:
49+
2. The resource owner creates a corresponding `SharedSecret` or `SharedConfigMap` instance to
50+
make the resource shareable. The resource owner should also create a `ClusterRole` that grants
51+
subjects permission to `use` the referenced shared resource.
5052

5153
```yaml
54+
---
5255
apiVersion: sharedresource.openshift.io/v1alpha1
5356
kind: SharedConfigMap
5457
metadata:
55-
name: share-default-config
58+
name: share-test-config
5659
spec:
5760
configMapRef:
5861
name: shared-config
59-
namespace: default
62+
namespace: test-share-source # The "source" namespace"
63+
---
64+
apiVersion: rbac.authorization.k8s.io/v1
65+
kind: ClusterRole
66+
metadata:
67+
name: shared-configmap-use-share-test-config
68+
rules:
69+
- apiGroups:
70+
- sharedresource.openshift.io
71+
resources:
72+
- sharedconfigmaps
73+
resourceNames:
74+
- share-test-config
75+
verbs:
76+
- use
6077
```
6178

62-
3. The resource owner then creates a `Clusterrole` and `Clusterrolebinding` to grant permission
63-
to the `ServiceAccount` of `csi-driver-shared-resource` to access
64-
the given resources.
79+
3. The resource owner then creates a `Role` and `RoleBinding` in the source namespace that grants
80+
the Shared Resource CSI driver permission to read and watch the referenced ConfigMap:
6581

6682
```yaml
6783
---
6884
apiVersion: rbac.authorization.k8s.io/v1
69-
kind: ClusterRole
85+
kind: Role
7086
metadata:
71-
name: shared-resource-secret-configmap-share-watch-sar-create
87+
name: shared-test-config
88+
namespace: test-share-source # This is the source namespace
7289
rules:
7390
- apiGroups: [""]
7491
resources: ["configmaps"]
7592
resourceNames: ["shared-config"]
7693
verbs: ["get", "list", "watch"]
77-
- apiGroups: ["sharedresource.openshift.io"]
78-
resources: ["sharedconfigmaps", "sharedsecrets"]
79-
verbs: ["get", "list", "watch"]
80-
- apiGroups: ["authorization.k8s.io"]
81-
resources: ["subjectaccessreviews"]
82-
verbs: ["create"]
8394
---
8495
apiVersion: rbac.authorization.k8s.io/v1
85-
kind: ClusterRoleBinding
96+
kind: RoleBinding
8697
metadata:
87-
name: shared-resource-secret-configmap-share-watch-sar-create
98+
name: shared-test-config
99+
namespace: test-share-source # This is the source namespace
88100
roleRef:
89101
apiGroup: rbac.authorization.k8s.io
90-
kind: ClusterRole
91-
name: shared-resource-secret-configmap-share-watch-sar-create
102+
kind: Role
103+
name: shared-test-config
92104
subjects:
93-
- kind: ServiceAccount
94-
name: csi-driver-shared-resource
95-
namespace: openshift-builds
105+
# The service account for the Shared Resource CSI driver DaemonSet must be listed here.
106+
# When deployed with Builds for OpenShift, the service account name is
107+
# `csi-driver-shared-resource`, and the namespace is the same one where the Builds for
108+
# OpenShift operator is deployed.
109+
- kind: ServiceAccount
110+
name: csi-driver-shared-resource
111+
namespace: openshift-builds
96112
```
97113
98-
4. The resource owner grants the desired `SeviceAccount` in the "target"
114+
4. Finally, the resource owner grants the desired `SeviceAccount` in the "target"
99115
namespace permission to use the shared resource above:
100116

101117
```yaml
102118
---
103119
apiVersion: rbac.authorization.k8s.io/v1
104-
kind: Role
105-
metadata:
106-
name: use-shared-default-config
107-
namespace: app-namespace # This is the "target" namespace
108-
rules:
109-
- apiGroups:
110-
- sharedresource.openshift.io
111-
resources:
112-
- sharedconfigmaps
113-
resourceNames:
114-
- share-default-config
115-
verbs:
116-
- use
117-
---
118-
apiVersion: rbac.authorization.k8s.io/v1
119120
kind: RoleBinding
120121
metadata:
121-
name: use-shared-default-config
122+
name: use-shared-config
122123
namespace: app-namespace
123124
roleRef:
124125
apiGroup: rbac.authorization.k8s.io
125-
kind: Role
126-
name: use-shared-default-config
126+
kind: ClusterRole
127+
name: use-shared-config
127128
subjects:
128129
- kind: ServiceAccount
129-
name: default
130-
namespace: app-namespace
130+
name: default # or other ServiceAccount specific to the application
131+
namespace: app-namespace # This is the "target" namespace
131132
```
132133

133-
5. The resource consumer mounts the shared resource into a `Pod` (or other
134-
resource that accepts `CSI` Volumes):
134+
5. The resource consumer mounts the shared resource into a `Pod` (or other resource that accepts
135+
`CSI` Volumes):
135136

136137
```yaml
137138
apiVersion: v1
@@ -148,7 +149,7 @@ the given resources.
148149
readOnly: true # required to be true
149150
driver: csi.sharedresource.openshift.io
150151
volumeAttributes:
151-
sharedConfigMap: share-default-config
152+
sharedConfigMap: share-test-config # This must match the name of the SharedConfigMap
152153
```
153154

154155
See also:

0 commit comments

Comments
 (0)