homelab-gitops/platform/kyverno/policies/30-disallow/disallow-host-namespace.yaml
gwg313 baa0216960
add kyverno policies
Signed-off-by: gwg313 <gwg313@pm.me>
2026-05-28 20:09:06 -04:00

35 lines
891 B
YAML

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-host-namespace
spec:
validationFailureAction: Enforce
background: true
rules:
- name: no-host-namespaces
match:
any:
- resources:
kinds:
- Pod
- Deployment
- StatefulSet
- DaemonSet
validate:
message: "Host networking, PID, and IPC are not allowed."
deny:
conditions:
any:
- key: "{{ request.object.spec.hostNetwork || false }}"
operator: Equals
value: true
- key: "{{ request.object.spec.hostPID || false }}"
operator: Equals
value: true
- key: "{{ request.object.spec.hostIPC || false }}"
operator: Equals
value: true