-
Notifications
You must be signed in to change notification settings - Fork 0
/
validating_resources_test.rego
54 lines (51 loc) · 1.03 KB
/
validating_resources_test.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package kubernetes.validating.resources
test_requests {
violation[{"msg": "You must provide resources.requests for container: only-limits"}] with input as pod
}
test_limits {
violation[{"msg": "You must provide resources.limits for container: only-requests"}] with input as pod
}
pod := {
"kind": "AdmissionReview",
"review": {
"kind": {
"kind": "Pod",
"version": "v1",
},
"object": {
"metadata": {"name": "requests-and-limits"},
"spec": {"containers": [
{
"image": "nginx",
"name": "requests-and-limits",
"resources": {
"limits": {
"cpu": "100m",
"memory": "256Mi",
},
"requests": {
"cpu": "50m",
"memory": "128Mi",
},
},
},
{
"image": "nginx",
"name": "only-limits",
"resources": {"limits": {
"cpu": "100m",
"memory": "256Mi",
}},
},
{
"image": "nginx",
"name": "only-requests",
"resources": {"requests": {
"cpu": "100m",
"memory": "256Mi",
}},
},
]},
},
},
}