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. This policy ensures no hostPath volumes are in use.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: disallow-host-pathannotations:policies.kyverno.io/title: Disallow hostPathpolicies.kyverno.io/category: Pod Security Standards (Baseline)policies.kyverno.io/severity: mediumpolicies.kyverno.io/subject: Pod,Volumekyverno.io/kyverno-version: 1.6.0kyverno.io/kubernetes-version: 1.22-1.23policies.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. This policy ensures no hostPath volumes are in use.spec:validationFailureAction: Auditbackground: truerules:- name: host-pathmatch:any:- resources:kinds:- Podvalidate:message: HostPath volumes are forbidden. The field spec.volumes[*].hostPath must be unset.pattern:spec:"=(volumes)":- X(hostPath): "null"
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.