{{- if or .Values.podSecurityPolicy.enabled (not .Values.rbac.clusterscoped) }}
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ include "goldpinger.fullname" . }}-pod-security-policy
  labels:
    {{- include "goldpinger.labels" . | nindent 4 }}
roleRef:
  kind: Role
  name: {{ include "goldpinger.fullname" . }}-pod-security-policy
  apiGroup: rbac.authorization.k8s.io
subjects:
  - kind: ServiceAccount
    name: {{ include "goldpinger.serviceAccountName" . }}
    namespace: {{ .Release.Namespace }}
{{- end }}
