mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
9d28116eb4
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
43 lines
1.3 KiB
YAML
43 lines
1.3 KiB
YAML
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: require-run-as-nonroot
|
|
spec:
|
|
validationFailureAction: Enforce
|
|
background: true
|
|
rules:
|
|
- name: run-as-non-root
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
validate:
|
|
message: >-
|
|
Running as root is not allowed. Either the field spec.securityContext.runAsNonRoot
|
|
must be set to `true`, or the fields spec.containers[*].securityContext.runAsNonRoot,
|
|
spec.initContainers[*].securityContext.runAsNonRoot, and spec.ephemeralContainers[*].securityContext.runAsNonRoot
|
|
must be set to `true`.
|
|
anyPattern:
|
|
- spec:
|
|
securityContext:
|
|
runAsNonRoot: "true"
|
|
=(ephemeralContainers):
|
|
- =(securityContext):
|
|
=(runAsNonRoot): "true"
|
|
=(initContainers):
|
|
- =(securityContext):
|
|
=(runAsNonRoot): "true"
|
|
containers:
|
|
- =(securityContext):
|
|
=(runAsNonRoot): "true"
|
|
- spec:
|
|
=(ephemeralContainers):
|
|
- securityContext:
|
|
runAsNonRoot: "true"
|
|
=(initContainers):
|
|
- securityContext:
|
|
runAsNonRoot: "true"
|
|
containers:
|
|
- securityContext:
|
|
runAsNonRoot: "true"
|