{{- if and .Values.haproxy.podSecurityPolicy.create .Values.haproxy.enabled }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
  name: {{ template "redis-ha.fullname" . }}-haproxy
  labels:
{{ include "labels.standard" . | indent 4 }}
    component: {{ template "redis-ha.fullname" . }}-haproxy
spec:
  allowPrivilegeEscalation: false
  fsGroup:
    rule: 'MustRunAs'
    ranges:
      - min: {{ .Values.haproxy.securityContext.fsGroup }}
        max: {{ .Values.haproxy.securityContext.fsGroup }}
  hostIPC: false
  hostNetwork: false
  hostPID: false
  privileged: false
  readOnlyRootFilesystem: false
  requiredDropCapabilities:
    - ALL
  runAsUser:
    rule: 'MustRunAs'
    ranges:
      - min: {{ .Values.haproxy.securityContext.runAsUser }}
        max: {{ .Values.haproxy.securityContext.runAsUser }}
  seLinux:
    rule: 'RunAsAny'
  supplementalGroups:
    rule: 'MustRunAs'
    ranges:
      - min: {{ .Values.haproxy.securityContext.runAsUser }}
        max: {{ .Values.haproxy.securityContext.runAsUser }}
  volumes:
    - 'configMap'
    - 'secret'
    - 'emptyDir'
{{- end -}}
