{{- if and .Values.forwarder.enabled .Values.forwarder.rbac.create }}
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ include "fluentd.fullname" . }}
  labels: {{- include "fluentd.labels" . | nindent 4 }}
roleRef:
  kind: ClusterRole
  apiGroup: rbac.authorization.k8s.io
  name: {{ template "fluentd.fullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "fluentd.forwarder.serviceAccountName" . }}
    namespace: {{ .Release.Namespace }}
{{- end }}
