SV-257566r961620_rule
V-257566
SRG-APP-000435-CTR-001070
CNTR-OS-000810
CAT II
10
Add a resource quota to an existing project namespace by performing the following steps:
1. Create <YOURFILE>.yaml and insert the desired resource quota content. The following is an example resource quota definition.
apiVersion: v1
kind: ResourceQuota
metadata:
name: compute-resources
namespace: <NAMESPACE>
spec:
hard:
pods: "4"
requests.cpu: "1"
requests.memory: 1Gi
requests.ephemeral-storage: 2Gi
limits.cpu: "2"
limits.memory: 2Gi
limits.ephemeral-storage: 4Gi
2. Apply the ResourceQuota definition to the project namespace by executing the following:
oc apply -f <YOURFILE>.yaml -n <NAMESPACE>
Details regarding the configuration of resource quotas can be reviewed at https://docs.openshift.com/container-platform/4.8/applications/quotas/quotas-setting-per-project.html.
Note: CNTR-OS-000140 is a prerequisite to this control. A Network Policy must exist to run this check.
Verify that each user namespace has a ResourceQuota defined by executing the following:
for ns in $(oc get namespaces -ojson | jq -r '.items[] | select((.metadata.name | startswith("openshift") | not) and (.metadata.name | startswith("kube-") | not) and .metadata.name != "default") | .metadata.name '); do oc get resourcequota -n$ns; done
If the above returns any lines saying "No resources found in <PROJECT> namespace.", this is a finding. Empty output is not a finding.
V-257566
False
CNTR-OS-000810
Note: CNTR-OS-000140 is a prerequisite to this control. A Network Policy must exist to run this check.
Verify that each user namespace has a ResourceQuota defined by executing the following:
for ns in $(oc get namespaces -ojson | jq -r '.items[] | select((.metadata.name | startswith("openshift") | not) and (.metadata.name | startswith("kube-") | not) and .metadata.name != "default") | .metadata.name '); do oc get resourcequota -n$ns; done
If the above returns any lines saying "No resources found in <PROJECT> namespace.", this is a finding. Empty output is not a finding.
M
5547