1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/deployments-setting-resources.adoc
2024-03-15 12:15:52 +00:00

69 lines
2.3 KiB
Plaintext

// Module included in the following assemblies:
//
// * applications/deployments/managing-deployment-processes.adoc
:_mod-docs-content-type: PROCEDURE
[id="deployments-setting-resources_{context}"]
= Setting deployment resources
A deployment is completed by a pod that consumes resources (memory, CPU, and ephemeral storage) on a node. By default, pods consume unbounded node resources. However, if a project specifies default container limits, then pods consume resources up to those limits.
[NOTE]
====
The minimum memory limit for a deployment is 12 MB. If a container fails to start due to a `Cannot allocate memory` pod event, the memory limit is too low. Either increase or remove the memory limit. Removing the limit allows pods to consume unbounded node resources.
====
You can also limit resource use by specifying resource limits as part of the deployment strategy. Deployment resources can be used with the recreate, rolling, or custom deployment strategies.
.Procedure
. In the following example, each of `resources`, `cpu`, `memory`, and `ephemeral-storage` is optional:
+
[source,yaml]
----
kind: Deployment
apiVersion: apps/v1
metadata:
name: hello-openshift
# ...
spec:
# ...
type: "Recreate"
resources:
limits:
cpu: "100m" <1>
memory: "256Mi" <2>
ephemeral-storage: "1Gi" <3>
----
<1> `cpu` is in CPU units: `100m` represents 0.1 CPU units (100 * 1e-3).
<2> `memory` is in bytes: `256Mi` represents 268435456 bytes (256 * 2 ^ 20).
<3> `ephemeral-storage` is in bytes: `1Gi` represents 1073741824 bytes (2 ^ 30).
+
However, if a quota has been defined for your project, one of the following two items is required:
+
--
- A `resources` section set with an explicit `requests`:
+
[source,yaml]
----
kind: Deployment
apiVersion: apps/v1
metadata:
name: hello-openshift
# ...
spec:
# ...
type: "Recreate"
resources:
requests: <1>
cpu: "100m"
memory: "256Mi"
ephemeral-storage: "1Gi"
----
<1> The `requests` object contains the list of resources that correspond to the list of resources in the quota.
- A limit range defined in your project, where the defaults from the `LimitRange` object apply to pods created during the deployment process.
--
+
To set deployment resources, choose one of the above options. Otherwise, deploy pod creation fails, citing a failure to satisfy quota.