# helm_charts_server-rolebinding.yaml
{{- if and .Values.server.enabled .Values.rbac.create .Values.server.useExistingClusterRoleName .Values.server.namespaces -}}
{{ range $.Values.server.namespaces -}}
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  labels:
    {{- include "prometheus.server.labels" $ | nindent 4 }}
  name: {{ template "prometheus.server.fullname" $ }}
  namespace: {{ . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "prometheus.serviceAccountName.server" $ }}
{{ include "prometheus.namespace" $ | indent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ $.Values.server.useExistingClusterRoleName }}
{{ end -}}
{{ end -}}