2019-11-13 13:56:20 -08:00
|
|
|
apiVersion: "kyverno.io/v1"
|
2019-10-10 18:42:54 -07:00
|
|
|
kind: "ClusterPolicy"
|
|
|
|
metadata:
|
2019-11-09 16:33:19 -08:00
|
|
|
name: "disallow-bind-mounts"
|
2019-10-11 18:57:16 -07:00
|
|
|
annotations:
|
2019-11-11 18:21:16 -08:00
|
|
|
policies.kyverno.io/category: Workload Isolation
|
2019-10-30 12:59:51 -07:00
|
|
|
policies.kyverno.io/description: The volume of type `hostPath` allows pods to use host bind
|
2019-10-30 13:12:29 -07:00
|
|
|
mounts (i.e. directories and volumes mounted to a host path) in containers. Using host
|
2019-11-12 17:34:21 -08:00
|
|
|
resources can be used to access shared data or escalate privileges. Also, this couples pods
|
2019-10-30 13:12:29 -07:00
|
|
|
to a specific host and data persisted in the `hostPath` volume is coupled to the life of the
|
2019-11-12 17:34:21 -08:00
|
|
|
node leading to potential pod scheduling failures. It is highly recommended that applications
|
|
|
|
are designed to be decoupled from the underlying infrastructure (in this case, nodes).
|
2019-10-30 12:59:51 -07:00
|
|
|
|
2019-10-10 18:42:54 -07:00
|
|
|
spec:
|
|
|
|
rules:
|
2019-11-09 16:33:19 -08:00
|
|
|
- name: "validate-hostPath"
|
2019-10-10 18:42:54 -07:00
|
|
|
match:
|
|
|
|
resources:
|
|
|
|
kinds:
|
|
|
|
- "Pod"
|
|
|
|
validate:
|
2019-11-09 16:33:19 -08:00
|
|
|
message: "Host path volumes are not allowed"
|
2019-10-10 18:42:54 -07:00
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
volumes:
|
2019-11-12 17:34:21 -08:00
|
|
|
- X(hostPath): null
|