@@ -41,97 +41,98 @@ Sharing resources is done as follows:
41
41
kind : ConfigMap
42
42
metadata :
43
43
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
45
45
data :
46
46
config.txt : " Hello world!"
47
47
` ` `
48
48
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.
50
52
51
53
` ` ` yaml
54
+ ---
52
55
apiVersion: sharedresource.openshift.io/v1alpha1
53
56
kind: SharedConfigMap
54
57
metadata:
55
- name: share-default -config
58
+ name: share-test -config
56
59
spec:
57
60
configMapRef:
58
61
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
60
77
` ` `
61
78
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 :
65
81
66
82
` ` ` yaml
67
83
---
68
84
apiVersion: rbac.authorization.k8s.io/v1
69
- kind: ClusterRole
85
+ kind: Role
70
86
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
72
89
rules:
73
90
- apiGroups: [""]
74
91
resources: ["configmaps"]
75
92
resourceNames: ["shared-config"]
76
93
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"]
83
94
---
84
95
apiVersion: rbac.authorization.k8s.io/v1
85
- kind: ClusterRoleBinding
96
+ kind: RoleBinding
86
97
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
88
100
roleRef:
89
101
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
92
104
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
96
112
` ` `
97
113
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"
99
115
namespace permission to use the shared resource above :
100
116
101
117
` ` ` yaml
102
118
---
103
119
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
119
120
kind: RoleBinding
120
121
metadata:
121
- name: use-shared-default- config
122
+ name: use-shared-config
122
123
namespace: app-namespace
123
124
roleRef:
124
125
apiGroup: rbac.authorization.k8s.io
125
- kind: Role
126
- name: use-shared-default- config
126
+ kind: ClusterRole
127
+ name: use-shared-config
127
128
subjects:
128
129
- 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
131
132
` ` `
132
133
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) :
135
136
136
137
` ` ` yaml
137
138
apiVersion: v1
@@ -148,7 +149,7 @@ the given resources.
148
149
readOnly: true # required to be true
149
150
driver: csi.sharedresource.openshift.io
150
151
volumeAttributes:
151
- sharedConfigMap: share-default -config
152
+ sharedConfigMap: share-test -config # This must match the name of the SharedConfigMap
152
153
` ` `
153
154
154
155
See also :
0 commit comments