1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/test/best_practices/disallow_bind_mounts.yaml

27 lines
1 KiB
YAML
Raw Normal View History

2019-12-10 09:51:15 -08:00
apiVersion: kyverno.io/v1
kind: ClusterPolicy
2019-10-10 18:42:54 -07:00
metadata:
2019-12-10 09:51:15 -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-10 18:42:54 -07:00
spec:
validationFailureAction: audit
2019-10-10 18:42:54 -07:00
rules:
2019-12-10 09:51:15 -08:00
- name: validate-hostPath
2019-10-10 18:42:54 -07:00
match:
resources:
kinds:
2019-12-10 09:51:15 -08:00
- Pod
2019-10-10 18:42:54 -07:00
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):
- X(hostPath): "null"