{{- if .Values.podSecurityPolicy.enabled }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
  name: {{ template "efs-provisioner.fullname" . }}
  labels:
    app: {{ template "efs-provisioner.name" . }}
    env: {{ .Values.global.deployEnv }}
    chart: {{ template "efs-provisioner.chartname" . }}
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
{{- if .Values.podSecurityPolicy.annotations }}
  annotations:
{{ toYaml .Values.podSecurityPolicy.annotations | indent 4 }}
{{- end }}
spec:
  privileged: false
  allowPrivilegeEscalation: false
  requiredDropCapabilities:
    - ALL
  hostNetwork: false
  hostIPC: false
  hostPID: false
  volumes:
    - 'configMap'
    - 'secret'
    - 'nfs'
  runAsUser:
    rule: 'RunAsAny'    
  seLinux:
    rule: 'RunAsAny'
  supplementalGroups:
    rule: 'MustRunAs'
    ranges:
      - min: 1
        max: 65535
  fsGroup:
    rule: 'MustRunAs'
    ranges:
      - min: 1
        max: 65535
  readOnlyRootFilesystem: true
{{- end }}