Skip to content

Commit 688afb0

Browse files
authored
Merge pull request #31662 from Preeticp/pl_resource_consumption
Reducing resource consumption
2 parents 4061a2e + 20bcf8f commit 688afb0

File tree

4 files changed

+126
-1
lines changed

4 files changed

+126
-1
lines changed

_topic_map.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,9 @@ Topics:
13201320
File: uninstalling-pipelines
13211321
- Name: Creating CI/CD solutions for applications using OpenShift Pipelines
13221322
File: creating-applications-with-cicd-pipelines
1323-
- Name: Working with Pipelines using the Developer perspective
1323+
- Name: Reducing resource consumption of OpenShift Pipelines
1324+
File: reducing-pipelines-resource-consumption
1325+
- Name: Working with OpenShift Pipelines using the Developer perspective
13241326
File: working-with-pipelines-using-the-developer-perspective
13251327
- Name: OpenShift Pipelines release notes
13261328
File: op-release-notes
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[id="reducing-pipelines-resource-consumption"]
2+
= Reducing resource consumption of pipelines
3+
include::modules/common-attributes.adoc[]
4+
include::modules/pipelines-document-attributes.adoc[]
5+
:context: reducing-pipelines-resource-consumption
6+
7+
toc::[]
8+
9+
10+
If you use clusters in multi-tenant environments you must control the consumption of CPU, memory, and storage resources for each project and Kubernetes object. This helps prevent any one application from consuming too many resources and affecting other applications.
11+
12+
To define the final resource limits that are set on the resulting pods, {pipelines-title} use resource quota limits and limit ranges of the project in which they are executed.
13+
14+
To restrict resource consumption in your project, you can:
15+
16+
* xref:../../applications/quotas/quotas-setting-per-project.html[Set and manage resource quotas] to limit the aggregate resource consumption.
17+
* Use xref:../../nodes/clusters/nodes-cluster-limit-ranges.html[limit ranges to restrict resource consumption] for specific objects, such as pods, images, image streams, and persistent volume claims.
18+
19+
include::modules/op-understanding-pipelines-resource-consumption.adoc[leveloffset=+1]
20+
21+
include::modules/op-mitigating-extra-pipeline-resource-consumption.adoc[leveloffset=+1]
22+
23+
== Additional Resources
24+
25+
* xref:../../applications/quotas/quotas-setting-per-project.html[Resource Quotas]
26+
* xref:../../nodes/clusters/nodes-cluster-limit-ranges.html[Restricting resource consumption using limit ranges]
27+
* link:https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#resources[Resource requests and limits in Kubernetes]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Module included in the following assemblies:
2+
//
3+
// */openshift_pipelines/uninstalling-pipelines.adoc
4+
5+
[id='op-mitigating-extra-pipeline-resource-consumption_{context}']
6+
= Mitigating extra resource consumption in pipelines
7+
8+
When you have resource limits set on the containers in your pod, {product-title} sums up the resource limits requested as all containers run simultaneously.
9+
10+
To consume the minimum amount of resources needed to execute one step at a time in the invoked task, {pipelines-title} requests the maximum CPU, memory, and ephemeral storage as specified in the step that requires the most amount of resources. This ensures that the resource requirements of all the steps are met. Requests other than the maximum values are set to zero.
11+
12+
However, this behavior can lead to higher resource usage than required. If you use resource quotas, this could also lead to unschedulable pods.
13+
14+
For example, consider a task with two steps that uses scripts, and that does not define any resource limits and requests. The resulting pod has two init containers (one for entrypoint copy, the other for writing scripts) and two containers, one for each step.
15+
16+
{product-title} uses the limit range set up for the project to compute required resource requests and limits.
17+
For this example, set the following limit range in the project:
18+
19+
[source,yaml]
20+
----
21+
apiVersion: v1
22+
kind: LimitRange
23+
metadata:
24+
name: mem-min-max-demo-lr
25+
spec:
26+
limits:
27+
- max:
28+
memory: 1Gi
29+
min:
30+
memory: 500Mi
31+
type: Container
32+
----
33+
34+
In this scenario, each init container uses a request memory of 1Gi (the max limit of the limit range), and each container uses a request memory of 500Mi. Thus, the total memory request for the pod is 2Gi.
35+
36+
If the same limit range is used with a task of ten steps, the final memory request is 5Gi, which is higher than what each step actually needs, that is 500Mi (since each step runs after the other).
37+
38+
Thus, to reduce resource consumption of resources, you can:
39+
40+
* Reduce the number of steps in a given task by grouping different steps into one bigger step, using the script feature, and the same image. This reduces the minimum requested resource.
41+
* Distribute steps that are relatively independent of each other and can run on their own to multiple tasks instead of a single task. This lowers the number of steps in each task, making the request for each task smaller, and the scheduler can then run them when the resources are available.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Module included in the following assemblies:
2+
//
3+
// */openshift_pipelines/uninstalling-pipelines.adoc
4+
5+
[id='op-understanding-pipelines-resource-consumption_{context}']
6+
= Understanding resource consumption in pipelines
7+
8+
Each task consists of a number of required steps to be executed in a particular order defined in the `steps` field of the `Task` resource. Every task runs as a pod, and each step runs as a container within that pod.
9+
10+
Steps are executed one at a time. The pod that executes the task only requests enough resources to run a single container image (step) in the task at a time, and thus does not store resources for all the steps in the task.
11+
12+
The `Resources` field in the `steps` spec specifies the limits for resource consumption.
13+
By default, the resource requests for the CPU, memory, and ephemeral storage are set to `BestEffort` (zero) values or to the minimums set through limit ranges in that project.
14+
15+
.Example configuration of resource requests and limits for a step
16+
[source,yaml]
17+
----
18+
spec:
19+
steps:
20+
- name: <step_name>
21+
resources:
22+
requests:
23+
memory: 2Gi
24+
cpu: 600m
25+
limits:
26+
memory: 4Gi
27+
cpu: 900m
28+
----
29+
30+
When the `LimitRange` parameter and the minimum values for container resource requests are specified in the project in which the pipeline and task runs are executed, {pipelines-title} looks at all the `LimitRange` values in the project and uses the minimum values instead of zero.
31+
32+
.Example configuration of limit range parameters at a project level
33+
[source,yaml]
34+
----
35+
apiVersion: v1
36+
kind: LimitRange
37+
metadata:
38+
name: <limit_container_resource>
39+
spec:
40+
limits:
41+
- max:
42+
cpu: "600m"
43+
memory: "2Gi"
44+
min:
45+
cpu: "200m"
46+
memory: "100Mi"
47+
default:
48+
cpu: "500m"
49+
memory: "800Mi"
50+
defaultRequest:
51+
cpu: "100m"
52+
memory: "100Mi"
53+
type: Container
54+
...
55+
----

0 commit comments

Comments
 (0)