{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: {{ template "haproxy-ingress.fullname" . }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "haproxy-ingress.fullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "haproxy-ingress.serviceAccountName" . }}
    namespace: {{ .Release.Namespace }}
  - apiGroup: rbac.authorization.k8s.io
    kind: User
    name: {{ template "haproxy-ingress.fullname" . }}
{{- end -}}