1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/samples/RequireReadOnlyRootFS.md

30 lines
806 B
Markdown
Raw Normal View History

2019-11-12 17:39:12 -08:00
# Require read-only root filesystem
2019-10-23 14:06:03 -07:00
2019-10-23 15:36:37 -07:00
A read-only root file system helps to enforce an immutable infrastructure strategy; the container only needs to write on mounted volumes that can persist state even if the container exits. An immutable root filesystem can also prevent malicious binaries from writing to the host system.
2019-10-23 14:06:03 -07:00
## Policy YAML
2019-11-09 16:18:33 -08:00
[require_ro_rootfs.yaml](best_practices/require_ro_rootfs.yaml)
2019-10-23 14:06:03 -07:00
````yaml
2019-11-13 13:56:20 -08:00
apiVersion: kyverno.io/v1
2019-10-23 14:06:03 -07:00
kind: ClusterPolicy
metadata:
2019-11-09 16:18:33 -08:00
name: require-ro-rootfs
2019-10-23 14:06:03 -07:00
spec:
rules:
2019-11-09 16:18:33 -08:00
- name: validate-readOnlyRootFilesystem
2019-10-23 14:06:03 -07:00
match:
resources:
kinds:
- Pod
validate:
2019-11-09 16:18:33 -08:00
message: "Root filesystem must be read-only"
2019-10-23 14:06:03 -07:00
pattern:
spec:
containers:
- securityContext:
readOnlyRootFilesystem: true
2019-11-12 17:39:12 -08:00
````