2019-07-17 13:33:05 -07:00
|
|
|
apiVersion : kyverno.io/v1alpha1
|
|
|
|
kind: Policy
|
|
|
|
metadata:
|
|
|
|
name: container-security-context
|
|
|
|
spec:
|
|
|
|
rules:
|
2019-07-17 17:09:18 -07:00
|
|
|
- name: validate-user-privilege
|
2019-07-25 14:57:44 -04:00
|
|
|
match:
|
|
|
|
resources:
|
|
|
|
kinds:
|
|
|
|
- Deployment
|
|
|
|
selector :
|
|
|
|
matchLabels:
|
|
|
|
app.type: prod
|
2019-07-17 13:33:05 -07:00
|
|
|
validate:
|
|
|
|
message: "validate container security contexts"
|
|
|
|
pattern:
|
|
|
|
spec:
|
|
|
|
template:
|
|
|
|
spec:
|
|
|
|
containers:
|
2019-07-17 17:09:18 -07:00
|
|
|
- securityContext:
|
|
|
|
runAsNonRoot: true
|
|
|
|
allowPrivilegeEscalation: false
|
|
|
|
# fields can be customized
|
2019-07-17 13:33:05 -07:00
|
|
|
# privileged: false
|
2019-07-29 19:01:17 -07:00
|
|
|
# readOnlyRootFilesystem: true
|