1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 08:26:53 +00:00
kyverno/samples/best_practices/deny_runasrootuser.yaml

28 lines
863 B
YAML
Raw Normal View History

2019-10-08 18:40:15 -07:00
apiVersion: kyverno.io/v1alpha1
kind: ClusterPolicy
metadata:
name: validate-deny-runasrootuser
2019-10-11 18:57:16 -07:00
annotations:
policies.kyverno.io/category: Security Context
2019-10-14 16:33:19 -07:00
policies.kyverno.io/description: By default, processes in a container run as a
root user (uid 0). To prevent potential compromise of container hosts, specify a
least privileged user ID when building the container image and require that
application containers run as non root users.
2019-10-08 18:40:15 -07:00
spec:
rules:
- name: deny-runasrootuser
match:
resources:
kinds:
- Pod
validate:
2019-11-01 15:00:05 -07:00
message: "Root user is not allowed. Set runAsNonRoot to true"
2019-10-08 18:40:15 -07:00
anyPattern:
- spec:
securityContext:
runAsNonRoot: true
- spec:
containers:
- name: "*"
securityContext:
runAsNonRoot: true