{{ if .Values.psp.create }}
{{ if .Values.psp.existingPspClusterRole }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: {{ .Values.psp.name }}
  {{- if .Values.namespace }}
  namespace: {{ toYaml .Values.namespace }}
  {{- end }}
  annotations:
  {{- include "custom.annotations" $ | indent 4 }}
  labels:
  {{- include "configseeder.labels" $ | indent 4 }}
  {{- include "custom.labels" $ | indent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ .Values.psp.existingPspClusterRole }}
subjects:
  - kind: ServiceAccount
    name: {{ .Values.serviceAccount.name }}
    {{- if .Values.namespace }}
    namespace: {{ toYaml .Values.namespace }}
    {{ end }}
{{ end }}
{{ end }}