mirror of
https://github.com/morten-olsen/homelab-apps.git
synced 2026-02-08 01:36:28 +01:00
33 lines
1.1 KiB
YAML
33 lines
1.1 KiB
YAML
apiVersion: kyverno.io/v1
|
|
kind: Policy
|
|
metadata:
|
|
name: enforce-immutable-filesystem
|
|
annotations:
|
|
policies.kyverno.io/category: Security
|
|
policies.kyverno.io/severity: medium
|
|
policies.kyverno.io/description: |
|
|
This policy automatically sets 'readOnlyRootFilesystem: true' for all containers
|
|
within new Pods, enforcing an immutable root filesystem. This enhances security
|
|
by preventing applications from writing to their root filesystem at runtime,
|
|
making it harder for attackers to persist changes or introduce malware.
|
|
spec:
|
|
validationFailureAction: Audit
|
|
rules:
|
|
- name: enforce-read-only-root-filesystem
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
mutate:
|
|
patchStrategicMerge:
|
|
spec:
|
|
containers:
|
|
- (name): '*' # Apply to all containers
|
|
securityContext:
|
|
readOnlyRootFilesystem: true
|
|
initContainers:
|
|
- (name): '*' # Apply to all init containers
|
|
securityContext:
|
|
readOnlyRootFilesystem: true
|