{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
  name: {{ template "graylog.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ template "graylog.name" . }}
    helm.sh/chart: {{ template "graylog.chart" . }}
    app.kubernetes.io/managed-by: "{{ .Release.Service }}"
    app.kubernetes.io/instance: "{{ .Release.Name }}"
    app.kubernetes.io/version: "{{ .Chart.AppVersion }}"
rules:
- apiGroups:
    - ""
  resources:
{{ toYaml .Values.rbac.resources | indent 4 }}
  verbs:
    - get
    - list
    - patch
{{- end -}}
