{{- if .Values.rbac.enabled -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    app: {{ template "application-gateway-kubernetes-ingress.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "application-gateway-kubernetes-ingress.fullname" . }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "application-gateway-kubernetes-ingress.fullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "application-gateway-kubernetes-ingress.serviceaccountname" . }}
    namespace: {{ .Release.Namespace }}
{{- end -}}