mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-13 15:57:31 +00:00
38 lines
1.2 KiB
YAML
38 lines
1.2 KiB
YAML
{{- $name := "disallow-host-ports" }}
|
|
{{- 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: >-
|
|
Access to host ports allows potential snooping of network traffic and should not be
|
|
allowed, or at minimum restricted to a known list.
|
|
labels: {{ include "kyverno-policies.labels" . | nindent 4 }}
|
|
app: kyverno
|
|
spec:
|
|
validationFailureAction: {{ .Values.validationFailureAction }}
|
|
background: true
|
|
rules:
|
|
- name: host-ports
|
|
match:
|
|
resources:
|
|
kinds:
|
|
- Pod
|
|
validate:
|
|
message: >-
|
|
Use of host ports is disallowed. The fields spec.containers[*].ports[*].hostPort
|
|
and spec.initContainers[*].ports[*].hostPort must be empty.
|
|
pattern:
|
|
spec:
|
|
=(initContainers):
|
|
- =(ports):
|
|
- X(hostPort): 0
|
|
containers:
|
|
- =(ports):
|
|
- X(hostPort): 0
|
|
{{- end -}}
|