{{ if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ include "sealed-secrets.fullname" . }}
  labels: {{- include "sealed-secrets.labels" . | nindent 4 }}
    {{- if .Values.rbac.labels }}
    {{- include "sealed-secrets.render" ( dict "value" .Values.rbac.labels "context" $) | nindent 4 }}
    {{- end }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: secrets-unsealer
subjects:
  - apiGroup: ""
    kind: ServiceAccount
    name: {{ include "sealed-secrets.serviceAccountName" . }}
    namespace: {{ include "sealed-secrets.namespace" . }}
{{ end }}
