-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdeny.rego
39 lines (31 loc) · 910 Bytes
/
deny.rego
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import data.kubernetes
name = input.metadata.name
#deny[msg] {
# input.kind == "Deployment"
# not input.spec.template.spec.securityContext.runAsNonRoot
#
# msg := "Containers must not run as root"
#}
deny[msg] {
input.kind == "Deployment"
not input.spec.selector.matchLabels.app.kubernetes.io/name
# not input.spec.selector.matchLabels.app
msg := "Containers must provide name/version label for pod selectors"
}
#deny[msg] {
# kubernetes.is_deployment
# not input.spec.template.spec.securityContext.runAsNonRoot
#
# msg = sprintf("Containers must not run as root in Deployment %s", [name])
#}
required_deployment_selectors {
input.spec.selector.matchLabels.app
input.spec.selector.matchLabels.release
}
#deny[msg] {
# kubernetes.is_deployment
# not required_deployment_selectors
#
# msg = sprintf("Deployment %s must provide app/release labels for pod selectors", [name])
#}