{{- if and .Values.rbac.create .Values.deployments.etcdOperator }}
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/{{ required "A valid .Values.rbac.apiVersion entry required!" .Values.rbac.apiVersion }}
metadata:
  name: {{ template "etcd-operator.fullname" . }}
  labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    app: {{ template "etcd-operator.name" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
subjects:
- kind: ServiceAccount
  name: {{ template "etcd-operator.serviceAccountName" . }}
  namespace: {{ .Release.Namespace }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "etcd-operator.fullname" . }}
{{- end }}
