@@ -18,58 +18,15 @@ limitations under the License.
18
18
apiVersion : rbac.authorization.k8s.io/v1
19
19
kind : ClusterRole
20
20
metadata :
21
- name : {{ include "spark-operator.controller.name" . }}
21
+ name : {{ include "spark-operator.controller.clusterRoleName" . }}
22
+ namespace : {{ .Release.Namespace }}
22
23
labels :
23
24
{{- include "spark-operator.controller.labels" . | nindent 4 }}
24
25
{{- with .Values.controller.rbac.annotations }}
25
26
annotations :
26
27
{{- toYaml . | nindent 4 }}
27
28
{{- end }}
28
29
rules :
29
- - apiGroups :
30
- - " "
31
- resources :
32
- - pods
33
- verbs :
34
- - get
35
- - list
36
- - watch
37
- - create
38
- - update
39
- - patch
40
- - delete
41
- - deletecollection
42
- - apiGroups :
43
- - " "
44
- resources :
45
- - configmaps
46
- verbs :
47
- - get
48
- - create
49
- - update
50
- - patch
51
- - delete
52
- - apiGroups :
53
- - " "
54
- resources :
55
- - services
56
- verbs :
57
- - get
58
- - list
59
- - watch
60
- - create
61
- - update
62
- - patch
63
- - delete
64
- - apiGroups :
65
- - extensions
66
- - networking.k8s.io
67
- resources :
68
- - ingresses
69
- verbs :
70
- - get
71
- - create
72
- - delete
73
30
- apiGroups :
74
31
- " "
75
32
resources :
@@ -90,63 +47,16 @@ rules:
90
47
- customresourcedefinitions
91
48
verbs :
92
49
- get
93
- - apiGroups :
94
- - sparkoperator.k8s.io
95
- resources :
96
- - sparkapplications
97
- - scheduledsparkapplications
98
- verbs :
99
- - get
100
- - list
101
- - watch
102
- - create
103
- - update
104
- - patch
105
- - delete
106
- - apiGroups :
107
- - sparkoperator.k8s.io
108
- resources :
109
- - sparkapplications/status
110
- - scheduledsparkapplications/status
111
- verbs :
112
- - get
113
- - update
114
- - patch
115
- - apiGroups :
116
- - sparkoperator.k8s.io
117
- resources :
118
- - sparkapplications/finalizers
119
- - scheduledsparkapplications/finalizers
120
- verbs :
121
- - update
122
- {{- if .Values.controller.batchScheduler.enable }}
123
- {{/* required for the `volcano` batch scheduler */}}
124
- - apiGroups :
125
- - scheduling.incubator.k8s.io
126
- - scheduling.sigs.dev
127
- - scheduling.volcano.sh
128
- resources :
129
- - podgroups
130
- verbs :
131
- - " *"
132
- - apiGroups :
133
- - scheduling.x-k8s.io
134
- resources :
135
- - podgroups
136
- verbs :
137
- - get
138
- - list
139
- - watch
140
- - create
141
- - update
142
- - delete
50
+ {{- if not .Values.spark.jobNamespaces | or (has "" .Values.spark.jobNamespaces) }}
51
+ {{ include "spark-operator.controller.policyRules" . }}
143
52
{{- end }}
144
53
---
145
54
146
55
apiVersion : rbac.authorization.k8s.io/v1
147
56
kind : ClusterRoleBinding
148
57
metadata :
149
- name : {{ include "spark-operator.controller.name" . }}
58
+ name : {{ include "spark-operator.controller.clusterRoleBindingName" . }}
59
+ namespace : {{ .Release.Namespace }}
150
60
labels :
151
61
{{- include "spark-operator.controller.labels" . | nindent 4 }}
152
62
{{- with .Values.controller.rbac.annotations }}
@@ -160,13 +70,14 @@ subjects:
160
70
roleRef :
161
71
apiGroup : rbac.authorization.k8s.io
162
72
kind : ClusterRole
163
- name : {{ include "spark-operator.controller.name" . }}
164
-
73
+ name : {{ include "spark-operator.controller.clusterRoleName" . }}
165
74
---
75
+
166
76
apiVersion : rbac.authorization.k8s.io/v1
167
77
kind : Role
168
78
metadata :
169
- name : {{ include "spark-operator.controller.name" . }}
79
+ name : {{ include "spark-operator.controller.roleName" . }}
80
+ namespace : {{ .Release.Namespace }}
170
81
labels :
171
82
{{- include "spark-operator.controller.labels" . | nindent 4 }}
172
83
{{- with .Values.controller.rbac.annotations }}
@@ -189,12 +100,16 @@ rules:
189
100
verbs :
190
101
- get
191
102
- update
192
-
103
+ {{- if has .Release.Namespace .Values.spark.jobNamespaces }}
104
+ {{ include "spark-operator.controller.policyRules" . }}
105
+ {{- end }}
193
106
---
107
+
194
108
apiVersion : rbac.authorization.k8s.io/v1
195
109
kind : RoleBinding
196
110
metadata :
197
- name : {{ include "spark-operator.controller.name" . }}
111
+ name : {{ include "spark-operator.controller.roleBindingName" . }}
112
+ namespace : {{ .Release.Namespace }}
198
113
labels :
199
114
{{- include "spark-operator.controller.labels" . | nindent 4 }}
200
115
{{- with .Values.controller.rbac.annotations }}
@@ -208,5 +123,48 @@ subjects:
208
123
roleRef :
209
124
apiGroup : rbac.authorization.k8s.io
210
125
kind : Role
211
- name : {{ include "spark-operator.controller.name" . }}
126
+ name : {{ include "spark-operator.controller.roleName" . }}
127
+
128
+ {{- if and .Values.spark.jobNamespaces (not (has "" .Values.spark.jobNamespaces)) }}
129
+ {{- range $jobNamespace := .Values.spark.jobNamespaces }}
130
+ {{- if ne $jobNamespace $.Release.Namespace }}
131
+ ---
132
+
133
+ apiVersion : rbac.authorization.k8s.io/v1
134
+ kind : Role
135
+ metadata :
136
+ name : {{ include "spark-operator.controller.roleName" $ }}
137
+ namespace : {{ $jobNamespace }}
138
+ labels :
139
+ {{- include "spark-operator.controller.labels" $ | nindent 4 }}
140
+ {{- with $.Values.controller.rbac.annotations }}
141
+ annotations :
142
+ {{- toYaml . | nindent 4 }}
143
+ {{- end }}
144
+ rules :
145
+ {{ include "spark-operator.controller.policyRules" $ }}
146
+ ---
147
+
148
+ apiVersion : rbac.authorization.k8s.io/v1
149
+ kind : RoleBinding
150
+ metadata :
151
+ name : {{ include "spark-operator.controller.roleBindingName" $ }}
152
+ namespace : {{ $jobNamespace }}
153
+ labels :
154
+ {{- include "spark-operator.controller.labels" $ | nindent 4 }}
155
+ {{- with $.Values.controller.rbac.annotations }}
156
+ annotations :
157
+ {{- toYaml . | nindent 4 }}
158
+ {{- end }}
159
+ subjects :
160
+ - kind : ServiceAccount
161
+ name : {{ include "spark-operator.controller.serviceAccountName" $ }}
162
+ namespace : {{ $.Release.Namespace }}
163
+ roleRef :
164
+ apiGroup : rbac.authorization.k8s.io
165
+ kind : Role
166
+ name : {{ include "spark-operator.controller.roleName" $ }}
167
+ {{- end }}
168
+ {{- end }}
169
+ {{- end }}
212
170
{{- end }}
0 commit comments