mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
32 lines
No EOL
1 KiB
YAML
32 lines
No EOL
1 KiB
YAML
{{ $name := "disallow-host-path" -}}
|
|
{{- if eq (include "kyverno.podSecurityDefault" (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.
|
|
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 -}} |