quorate/vendor/platform/kyverno/policies/restrict-pod-host-access.yaml

79 lines
2.2 KiB
YAML
Raw Permalink Normal View History

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: restrict-pod-host-access
annotations:
policies.kyverno.io/title: Restrict host namespaces and hostPath (audit)
policies.kyverno.io/category: Pod Security
policies.kyverno.io/severity: medium
policies.kyverno.io/description: >-
Audit Pod Security restricted host access (hostNetwork, hostPID, hostIPC,
hostPath). Complements deny-privileged; named exceptions for host agents.
spec:
validationFailureAction: Audit
background: true
rules:
- name: deny-host-namespaces
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- resources:
namespaces:
- kube-system
- kube-public
- kube-node-lease
- flux-system
- flux-canary
- kyverno
- cert-manager
- cilium-secrets
- olm
- operators
- longhorn
- openebs
- intel-system
- nfd
validate:
message: >-
Pods must not set hostNetwork, hostPID, or hostIPC (PSS restricted).
pattern:
spec:
=(hostNetwork): "false"
=(hostPID): "false"
=(hostIPC): "false"
- name: deny-hostpath-volumes
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- resources:
namespaces:
- kube-system
- kube-public
- kube-node-lease
- flux-system
- flux-canary
- kyverno
- cert-manager
- cilium-secrets
- olm
- operators
- longhorn
- openebs
- intel-system
- nfd
validate:
message: >-
Pods must not use hostPath volumes (PSS restricted). Prefer emptyDir,
PVC, or projected volumes.
pattern:
spec:
=(volumes):
- X(hostPath): "null"