{{- if .Values.rbac.pspEnabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ printf "%s-psp" (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 }}
    {{- if .Values.commonLabels }}
    {{- include "sealed-secrets.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
    {{- end }}
  annotations:
    {{- if .Values.commonAnnotations }}
    {{- include "sealed-secrets.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
    {{- end }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ printf "%s-psp" (include "sealed-secrets.fullname" .) }}
subjects:
  - kind: ServiceAccount
    name: {{ include "sealed-secrets.serviceAccountName" . }}
    namespace: {{ include "sealed-secrets.namespace" . }}
{{- end }}
