{{- if and (not .Values.connectInject.certs.secretName) (or (and (ne (.Values.connectInject.enabled | toString) "-") .Values.connectInject.enabled) (and (eq (.Values.connectInject.enabled | toString) "-") .Values.global.enabled)) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ template "consul.fullname" . }}-connect-injector-webhook-admin-role-binding
  labels:
    app: {{ template "consul.name" . }}
    chart: {{ template "consul.chart" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "consul.fullname" . }}-connect-injector-webhook
subjects:
  - kind: ServiceAccount
    name: {{ template "consul.fullname" . }}-connect-injector-webhook-svc-account
    namespace: {{ .Release.Namespace }}
{{- end }}
