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:
|
2020-08-19 14:04:58 -07:00
|
|
|
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:
|
2019-12-27 14:59:12 -08:00
|
|
|
=(volumes):
|
2020-09-15 22:58:55 -07:00
|
|
|
- X(hostPath): "null"
|