{{- if .Values.podSecurityPolicy.enabled }}
apiVersion: extensions/v1beta1
kind: PodSecurityPolicy
metadata:
  name: {{ template "fluentd-elasticsearch.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "fluentd-elasticsearch.name" . }}
    helm.sh/chart: {{ include "fluentd-elasticsearch.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile
  annotations:
{{- if .Values.podSecurityPolicy.annotations }}
{{ toYaml .Values.podSecurityPolicy.annotations | indent 4 }}
{{- end }}
spec:
  privileged: false
  allowPrivilegeEscalation: true
  volumes:
    - 'configMap'
    - 'emptyDir'
    - 'hostPath'
    - 'secret'
  allowedHostPaths:
    - pathPrefix: /var/log
      readOnly: false
    - pathPrefix: /var/lib/docker/containers
      readOnly: true
    - pathPrefix: /usr/lib64
      readOnly: true
  hostNetwork: false
  hostPID: false
  hostIPC: false
  runAsUser:
    rule: 'RunAsAny'
  runAsGroup:
    rule: 'RunAsAny'
  seLinux:
    rule: 'RunAsAny'
  supplementalGroups:
    rule: 'RunAsAny'
  fsGroup:
    rule: 'MustRunAs'
    ranges:
      - min: 1
        max: 65535
  readOnlyRootFilesystem: false
  hostPorts:
    - min: 1
      max: 65535
{{- end }}
