{{- if .Values.rbac.pspEnabled }}
apiVersion: {{ template "podsecuritypolicy.apiVersion" . }}
kind: PodSecurityPolicy
metadata:
  name: {{ template "cluster-autoscaler.fullname" . }}
  labels:
{{ include "cluster-autoscaler.labels" . | indent 4 }}
spec:
  # Prevents running in privileged mode
  privileged: false
  # Required to prevent escalations to root.
  allowPrivilegeEscalation: false
  requiredDropCapabilities:
    - ALL
  volumes:
    - 'configMap'
    - 'secret'
    - 'hostPath'
    - 'emptyDir'
    - 'projected'
    - 'downwardAPI'
  hostNetwork: {{ .Values.hostNetwork }}
  hostIPC: false
  hostPID: false
  runAsUser:
    rule: RunAsAny
  seLinux:
    rule: RunAsAny
  supplementalGroups:
    rule: 'MustRunAs'
    ranges:
      # Forbid adding the root group.
      - min: 1
        max: 65535
  fsGroup:
    rule: 'MustRunAs'
    ranges:
      # Forbid adding the root group.
      - min: 1
        max: 65535
  readOnlyRootFilesystem: false
{{- end }}
