|
1 | 1 | {{- if .Values.rbac.create -}} |
2 | 2 | {{ $rbac := .Files.Get "files/rbac.yaml" | fromYaml }} |
3 | 3 | {{ $rbacOpenShift := .Files.Get "files/rbac-openshift.yaml" | fromYaml }} |
4 | | -{{- $watchNamespaces := coalesce .Values.watchNamespaces .Values.namespaceOverride .Release.Namespace }} |
| 4 | +{{- $watchNamespaces := coalesce .Values.watchNamespaces .Values.namespaceOverride .Release.Namespace | splitList "," }} |
5 | 5 | {{- $namespaceScoped := false }} |
6 | 6 | {{- $isOpenShift := false }} |
7 | 7 | {{- if or (.Values.namespaceScope) (.Values.watchNamespaces) }} |
|
11 | 11 | {{- $isOpenShift = true }} |
12 | 12 | {{- end }} |
13 | 13 | {{- $operatorNamespace := .Release.Namespace }} |
14 | | -{{- range ( split "," $watchNamespaces ) }} |
| 14 | +{{- range $watchNamespaces }} |
15 | 15 | --- |
16 | 16 | apiVersion: rbac.authorization.k8s.io/v1 |
17 | 17 | kind: {{ if not $namespaceScoped }}Cluster{{ end }}Role |
@@ -48,4 +48,45 @@ roleRef: |
48 | 48 | name: {{ include "grafana-operator.fullname" $ }} |
49 | 49 | apiGroup: rbac.authorization.k8s.io |
50 | 50 | {{- end }} |
| 51 | +{{- if and $namespaceScoped (not (has .Release.Namespace $watchNamespaces)) }} |
| 52 | +--- |
| 53 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 54 | +kind: Role |
| 55 | +metadata: |
| 56 | + namespace: {{ .Release.Namespace }} |
| 57 | + name: {{ include "grafana-operator.fullname" $ }} |
| 58 | + labels: |
| 59 | + {{- include "grafana-operator.labels" $ | nindent 4 }} |
| 60 | + app.kubernetes.io/component: operator |
| 61 | +rules: |
| 62 | +- apiGroups: |
| 63 | + - coordination.k8s.io |
| 64 | + resources: |
| 65 | + - leases |
| 66 | + verbs: |
| 67 | + - get |
| 68 | + - list |
| 69 | + - watch |
| 70 | + - create |
| 71 | + - update |
| 72 | + - patch |
| 73 | + - delete |
| 74 | +--- |
| 75 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 76 | +kind: RoleBinding |
| 77 | +metadata: |
| 78 | + name: {{ include "grafana-operator.fullname" $ }} |
| 79 | + namespace: {{ .Release.Namespace }} |
| 80 | + labels: |
| 81 | + {{- include "grafana-operator.labels" $ | nindent 4 }} |
| 82 | + app.kubernetes.io/component: operator |
| 83 | +subjects: |
| 84 | + - kind: ServiceAccount |
| 85 | + name: {{ include "grafana-operator.serviceAccountName" $ }} |
| 86 | + namespace: {{ include "grafana-operator.namespace" $ }} |
| 87 | +roleRef: |
| 88 | + kind: Role |
| 89 | + name: {{ include "grafana-operator.fullname" $ }} |
| 90 | + apiGroup: rbac.authorization.k8s.io |
| 91 | +{{- end }} |
51 | 92 | {{- end }} |
0 commit comments