Skip to content

Commit 5359ffa

Browse files
committed
Add variable reference for resource_requests_limits rules
1 parent 74cf6d5 commit 5359ffa

File tree

3 files changed

+81
-1
lines changed
  • applications/openshift/general
    • resource_requests_limits_in_daemonset
    • resource_requests_limits_in_deployment
    • resource_requests_limits_in_statefulset

3 files changed

+81
-1
lines changed

applications/openshift/general/resource_requests_limits_in_daemonset/rule.yml

+26
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ description: |-
1212
for a container to use more resource than its request for that resource specifies.
1313
However, a container is not allowed to use more than its resource limit.
1414
15+
<p>
16+
To exempt a namespace with no resource requests/limits allocated in the daemonsets, the variable
17+
{{.var_daemonset_limit_namespaces_exempt_regex}} is being flagged.
18+
Namespaces matching the variable <tt>ocp4-var-daemonset-limit-namespaces-exempt-regex</tt> regex
19+
are excluded from this check.
20+
An example allowing an SCC named <tt>additional</tt> follows:
21+
</p>
22+
<pre>
23+
apiVersion: compliance.openshift.io/v1alpha1
24+
kind: TailoredProfile
25+
metadata:
26+
name: moderate-exempt-reource-request-limits
27+
spec:
28+
description: Allows an additional scc
29+
setValues:
30+
- name: ocp4-var-daemonset-limit-namespaces-exempt-regex
31+
rationale: set the value to namespaces to be exempted
32+
value: "test1|test2"
33+
extends: ocp4-moderate
34+
title: Modified moderate to exempt a namespace with no resource requests/limits in daemonset
35+
</pre>
36+
<p>
37+
Finally, reference this <tt>TailoredProfile</tt> in a <tt>ScanSettingBinding</tt>
38+
</p>
39+
1540
# todo : better if we can keep openshift document link for this reference,
1641

1742
rationale: |-
@@ -25,6 +50,7 @@ identifiers: {}
2550

2651
references:
2752
nist: SC-6
53+
2854
{{% set jqfilter = '[ .items[] | select(.metadata.namespace | startswith("kube-") or startswith("openshift-") | not) | select(.metadata.namespace != "rhacs-operator" and ({{if ne .var_daemonset_limit_namespaces_exempt_regex "None"}}.metadata.namespace | test("{{.var_daemonset_limit_namespaces_exempt_regex}}") | not{{else}}true{{end}})) | select( .spec.template.spec.containers[].resources.requests.cpu == null or .spec.template.spec.containers[].resources.requests.memory == null or .spec.template.spec.containers[].resources.limits.cpu == null or .spec.template.spec.containers[].resources.limits.memory == null ) | .metadata.name ]' %}}
2955
ocil_clause: 'Resource requests and limits is not set'
3056

applications/openshift/general/resource_requests_limits_in_deployment/rule.yml

+30-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,36 @@ description: |-
1212
for a container to use more resource than its request for that resource specifies.
1313
However, a container is not allowed to use more than its resource limit.
1414
15-
# todo : better if we can keep openshift document link for this reference,
15+
<p>
16+
To exempt a namespace with no resource requests/limits allocated in the one or more deployments, the variable
17+
{{.var_deployment_limit_namespaces_exempt_regex}} is being flagged.
18+
Namespaces matching the variable <tt>ocp4-var-deployment-limit-namespaces-exempt-regex</tt> regex
19+
are excluded from this check.
20+
An example allowing an SCC named <tt>additional</tt> follows:
21+
</p>
22+
<pre>
23+
apiVersion: compliance.openshift.io/v1alpha1
24+
kind: TailoredProfile
25+
metadata:
26+
name: moderate-exempt-reource-request-limits
27+
spec:
28+
description: Allows an additional scc
29+
setValues:
30+
- name: ocp4-var-deployment-limit-namespaces-exempt-regex
31+
rationale: set the value to namespaces to be exempted
32+
value: "test1|test2"
33+
extends: ocp4-moderate
34+
title: Modified moderate to exempt a namespace with no resource requests/limits in deployment
35+
</pre>
36+
<p>
37+
Finally, reference this <tt>TailoredProfile</tt> in a <tt>ScanSettingBinding</tt>
38+
</p>
39+
40+
<p>
41+
To configure resource requests/limits for a deployement, follow the directions in
42+
{{{ weblink(link="https://docs.openshift.com/container-platform/latest/applications/deployments/managing-deployment-processes.html#deployments-setting-resources_deployment-operations",
43+
text="the documentation") }}}
44+
</p>
1645
1746
rationale: |-
1847
Resource requests/limits provide constraints that limit aggregate resource consumption

applications/openshift/general/resource_requests_limits_in_statefulset/rule.yml

+25
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ description: |-
1212
for a container to use more resource than its request for that resource specifies.
1313
However, a container is not allowed to use more than its resource limit.
1414
15+
<p>
16+
To exempt a namespace with no resource requests/limits allocated in the one or more statefulsets, the variable
17+
{{.var_statefulset_limit_namespaces_exempt_regex}} is being flagged.
18+
Namespaces matching the variable <tt>ocp4-var-statefulset-limit-namespaces-exempt-regex</tt> regex
19+
are excluded from this check.
20+
An example allowing an SCC named <tt>additional</tt> follows:
21+
</p>
22+
<pre>
23+
apiVersion: compliance.openshift.io/v1alpha1
24+
kind: TailoredProfile
25+
metadata:
26+
name: moderate-exempt-reource-request-limits
27+
spec:
28+
description: Allows an additional scc
29+
setValues:
30+
- name: ocp4-var-statefulset-limit-namespaces-exempt-regex
31+
rationale: set the value to namespaces to be exempted
32+
value: "test1|test2"
33+
extends: ocp4-moderate
34+
title: Modified moderate to exempt a namespace with no resource requests/limits in statefulset
35+
</pre>
36+
<p>
37+
Finally, reference this <tt>TailoredProfile</tt> in a <tt>ScanSettingBinding</tt>
38+
</p>
39+
1540
# todo : better if we can keep openshift document link for this reference,
1641

1742
rationale: |-

0 commit comments

Comments
 (0)