Skip to content

Support Kubernetes extended resources for container components through attributes that override container and pod specification #920

Closed
@l0rd

Description

@l0rd

/area api

Which functionality do you think we should add?

Why is this needed? Is your feature request related to a problem?

Devfiles don't allow to specify request/limits for resources other than memory and CPU. But there are cases where developers workloads require extended resources (e.g. nvidia.com/gpu).

Detailed description:

Kubernetes nodes can be assigned with extended resources (besides memory and CPU) and workloads can request and limit the use of those resources.

For example NVIDIA GPU operator advertises nvidia.com/gpu resources on the cluster nodes so that a Pod that requires them can specify the request and limit quantities:

  apiVersion: v1
  kind: Pod
  metadata:
    name: python
  spec:
    containers:
      - name: python
        image: tensorflow/tensorflow:latest-gpu-jupyter
        resources:
          limits:
            memory: 4Gi
            nvidia.com/gpu: 1 # limiting to 1 GPU
          requests:
            nvidia.com/gpu: 1 # requesting 1 GPU

Describe the solution you'd like

Use devfile and components attributes to override pod and container spec:

JSON container overrides

schemaVersion: 2.1.0
metadata:
    name: python
components:
  - name: python
+   attributes:
+     container-overrides: {"resources": {"limits": {"nvidia.com/gpu": 1"}}}
    container:
      image: tensorflow/tensorflow:latest-gpu-jupyter
      (...)

YAML container overrides

schemaVersion: 2.1.0
metadata:
    name: python
components:
  - name: python
+   attributes:
+     container-overrides:
+       resources:
+         limits:
+           nvidia.com/gpu: 1
    container:
      image: tensorflow/tensorflow:latest-gpu-jupyter
      (...)

pod overrides at devfile attributes level (both YAML and JSON are supported)

schemaVersion: 2.1.0
metadata:
    name: python
+ attributes:
+   pod-overrides: {"spec": {"securityContext": {"allowPrivilegeEscalation": false}}}
components:
  - name: python
    container:
      image: tensorflow/tensorflow:latest-gpu-jupyter
      (...)

pod overrides at container attributes level (both YAML and JSON are supported)

schemaVersion: 2.1.0
metadata:
    name: python
components:
  - name: python
+   attributes:
+      pod-overrides: {"spec": {"schedulerName": "stork"}}
    container:
      image: tensorflow/tensorflow:latest-gpu-jupyter
      (...)

Additional context

The request comes from OpenShift Dev Spaces customers that were able to achieve that with devfile v1 kubernetes components. With devfile v2 kubernetes components run in their own pod and may not have access to the source code (that is mounted in the main pod).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done ✅

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions