1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-09 09:26:54 +00:00
kyverno/samples/best_practices/deny_runasrootuser.yaml
Shuting Zhao c6d5ec7575 Merge commit '82647670a54ead965c8cb964f3063409d0826070' into 337_policy_description
# Conflicts:
#	pkg/testrunner/testrunner_test.go
#	samples/README.md
#	samples/best_practices/policy_validate_deny_runasrootuser.yaml
#	test/scenarios/samples/best_practices/scenario_validate_nonRootUser.yaml
2019-10-15 12:27:22 -07:00

28 lines
No EOL
864 B
YAML

apiVersion: kyverno.io/v1alpha1
kind: ClusterPolicy
metadata:
name: validate-deny-runasrootuser
annotations:
policies.kyverno.io/category: Security Context
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.
spec:
rules:
- name: deny-runasrootuser
match:
resources:
kinds:
- Pod
validate:
message: "Root user is not allowed. Set runAsNonRoot to true."
anyPattern:
- spec:
securityContext:
runAsNonRoot: true
- spec:
containers:
- name: "*"
securityContext:
runAsNonRoot: true