{{- $name := "disallow-host-path" }} {{- if eq (include "kyverno-policies.podSecurityBaseline" (merge (dict "name" $name) .)) "true" }} apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: {{ $name }} annotations: policies.kyverno.io/category: Pod Security Standards (Default) {{- if .Values.podSecuritySeverity }} policies.kyverno.io/severity: {{ .Values.podSecuritySeverity | quote }} {{- end }} policies.kyverno.io/description: >- HostPath volumes let pods use host directories and volumes in containers. Using host resources can be used to access shared data or escalate privileges and should not be allowed. labels: {{ include "kyverno-policies.labels" . | nindent 4 }} app: kyverno spec: validationFailureAction: {{ .Values.validationFailureAction }} background: true rules: - name: host-path match: resources: kinds: - Pod validate: message: >- HostPath volumes are forbidden. The fields spec.volumes[*].hostPath must not be set. pattern: spec: =(volumes): - X(hostPath): "null" {{- end -}}