1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-10 01:46:55 +00:00
kyverno/examples/best_practices/validate_container_security_context.yaml

52 lines
1.2 KiB
YAML
Raw Normal View History

2019-09-03 11:27:04 -07:00
apiVersion: kyverno.io/v1alpha1
2019-09-04 11:29:46 -07:00
kind: ClusterPolicy
2019-09-03 11:27:04 -07:00
metadata:
name: check-container-security-context
spec:
validationFailureAction: "audit"
rules:
- name: check-root-user
exclude:
resources:
2019-09-04 11:08:56 -07:00
namespaces:
- kube-system
2019-09-03 11:27:04 -07:00
match:
resources:
kinds:
- Pod
validate:
message: "Root user is not allowed. Set runAsNonRoot to true."
anyPattern:
- spec:
securityContext:
runAsNonRoot: true
# pattern:
# spec:
# containers:
# - name: "*"
# securityContext:
# runAsNonRoot: true
2019-09-03 11:27:04 -07:00
- name: check-privilege
exclude:
resources:
2019-09-04 11:08:56 -07:00
namespaces:
- kube-system
2019-09-03 11:27:04 -07:00
match:
resources:
kinds:
- Pod
validate:
message: "Privileged mode is not allowed. Set allowPrivilegeEscalatin and privileged to false"
anyPattern:
- spec:
securityContext:
allowPrivilegeEscalation: false
privileged: false
# pattern:
# spec:
# containers:
# - name: "*"
# securityContext:
# allowPrivilegeEscalation: false
# privileged: false