# Based on https://kyverno.io/policies/pod-security/baseline/disallow-host-namespaces/disallow-host-namespaces/ apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: disallow-host-namespaces annotations: policies.kyverno.io/category: Pod Security Standards (Baseline) policies.kyverno.io/severity: medium policies.kyverno.io/subject: Pod policies.kyverno.io/description: >- Host namespaces (Process ID namespace, Inter-Process Communication namespace, and network namespace) allow access to shared information and can be used to elevate privileges. Pods should not be allowed access to host namespaces. spec: validationFailureAction: audit background: true rules: - name: host-namespaces match: resources: kinds: - Pod # allow host namespaces on kube-system and calico-system exclude: resources: namespaces: - calico-system - tigera-operator - monitoring validate: message: >- Sharing the host namespaces is disallowed. The fields spec.hostNetwork, spec.hostIPC, and spec.hostPID must not be set to true. pattern: spec: =(hostPID): "false" =(hostIPC): "false" =(hostNetwork): "false"