mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
126 lines
3.6 KiB
Plaintext
126 lines
3.6 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * nodes/nodes-pods-allocate-dra.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="nodes-pods-allocate-dra-configure_{context}"]
|
|
= Adding resource claims to pods
|
|
|
|
[role="_abstract"]
|
|
You can use resource claims and resource claim templates with {attribute-based-full} to allow you to request your workloads to be scheduled on nodes with specific graphics processing units (GPU).
|
|
|
|
Resource claims can be used with multiple pods, but resource claim templates can be used with only one pod. For more information, see "About GPU allocation objects and concepts".
|
|
|
|
The example in the following procedure creates a resource claim to schedule a pod on a node with the assign a specific GPU to and a resource claim to share a GPU between `container1` and `container2`.
|
|
|
|
.Prerequisites
|
|
|
|
* A Dynamic Resource Allocation (DRA) driver is installed. For more information on DRA, see link:https://kubernetes.io/docs/concepts/scheduling-eviction/dynamic-resource-allocation/["Dynamic Resource Allocation"] (Kubernetes documentation).
|
|
* A resource slice has been created.
|
|
* A resource claim and/or resource claim template has been created.
|
|
+
|
|
.Example resource claim object
|
|
[source,yaml]
|
|
----
|
|
apiVersion: resource.k8s.io/v1
|
|
kind: ResourceClaim
|
|
metadata:
|
|
namespace: gpu-claim
|
|
name: gpu-devices
|
|
spec:
|
|
devices:
|
|
requests:
|
|
- name: req-0
|
|
exactly:
|
|
name: 2g-10gb
|
|
deviceClassName: example-device-class
|
|
selectors:
|
|
- cel:
|
|
expression: "device.attributes['driver.example.com'].profile == '2g.10gb'"
|
|
----
|
|
+
|
|
.Example resource claim template object
|
|
[source,yaml]
|
|
----
|
|
apiVersion: resource.k8s.io/v1
|
|
kind: ResourceClaimTemplate
|
|
metadata:
|
|
namespace: gpu-claim
|
|
name: gpu-devices
|
|
spec:
|
|
spec:
|
|
devices:
|
|
requests:
|
|
- name: req-0
|
|
firstAvailable:
|
|
- name: 2g-10gb
|
|
deviceClassName: example-device-class
|
|
selectors:
|
|
- cel:
|
|
expression: "device.attributes['driver.example.com'].profile == '2g.10gb'"
|
|
- name: 3g-20gb
|
|
deviceClassName: example-device-class
|
|
selectors:
|
|
- cel:
|
|
expression: "device.attributes['driver.example.com'].profile == '3g.20gb'"
|
|
----
|
|
|
|
.Procedure
|
|
|
|
. Create a pod by creating a YAML file similar to the following:
|
|
+
|
|
.Example pod that is requesting resources
|
|
[source,yaml]
|
|
----
|
|
apiVersion: v1
|
|
kind: Pod
|
|
metadata:
|
|
namespace: gpu-allocate
|
|
name: pod1
|
|
labels:
|
|
app: pod
|
|
spec:
|
|
restartPolicy: Never
|
|
containers:
|
|
- name: container0
|
|
image: ubuntu:24.04
|
|
command: ["sleep", "9999"]
|
|
resources:
|
|
claims:
|
|
- name: gpu-claim-template
|
|
- name: container1
|
|
image: ubuntu:24.04
|
|
command: ["sleep", "9999"]
|
|
resources:
|
|
claims:
|
|
- name: gpu-claim
|
|
- name: container2
|
|
image: ubuntu:24.04
|
|
command: ["sleep", "9999"]
|
|
resources:
|
|
claims:
|
|
- name: gpu-claim
|
|
resourceClaims:
|
|
- name: gpu-claim-template
|
|
resourceClaimTemplateName: gpu-devices-template
|
|
- name: gpu-claim
|
|
resourceClaimName: gpu-devices
|
|
----
|
|
+
|
|
--
|
|
where:
|
|
|
|
`spec.container.resource.claims`:: Specifies one or more resource claims to use with this container.
|
|
|
|
`spec.resourceClaims`:: Specifies the resource claims that are required for the containers to start. Include an arbitrary name for the resource claim request and a resource claim, resource claim template, or both.
|
|
--
|
|
|
|
. Create the CRD object:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc create -f <file_name>.yaml
|
|
----
|
|
|
|
For more information on configuring pod resource requests, see link:https://kubernetes.io/docs/concepts/scheduling-eviction/dynamic-resource-allocation/["Dynamic Resource Allocation"] (Kubernetes documentation).
|