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