Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55887

Allow addition of custom resource limits in kubernetes containers

      Description
      Currently, it is not possible to add custom resource limits to kubernetes containers unless you write raw yaml.
      A rudimentary example would be:

      ...
         containers:
          - name: NAME
            ...
            resources:
              limits:
                nvidia.com/gpu: 1 # requesting 1 GPU
      ...
      

      Here the last line cannot be added easily with the interface.

      Possible Solution
      Add this functionality similar to the EnvVars variable, where multiple limits can be defined by hand with name and value. So basically replace EnvVars with limits in the following screenshot:

      Additional Context
      A complete example (not for jenkins) would be:

      apiVersion: v1
      kind: Pod
      metadata:
        name: cuda-vector-add
        namespace: nvidia 
      spec: 
        restartPolicy: OnFailure
        serviceAccount: nvidia-deviceplugin
        serviceAccountName: nvidia-deviceplugin
        containers:
          - name: cuda-vector-add
            image: "docker.io/mirrorgooglecontainers/cuda-vector-add:v0.1"
            env:
              - name: NVIDIA_VISIBLE_DEVICES
                value: all
              - name: NVIDIA_DRIVER_CAPABILITIES
                value: "compute,utility"
              - name: NVIDIA_REQUIRE_CUDA
                value: "cuda>=5.0"
            securityContext:
              privileged: true
            resources:
              limits:
                nvidia.com/gpu: 1 # requesting 1 GPU
      

          [JENKINS-55887] Allow addition of custom resource limits in kubernetes containers

          the yaml option is there so we don't need to write new ui/methods for each possible k8s api option

          Carlos Sanchez added a comment - the yaml option is there so we don't need to write new ui/methods for each possible k8s api option

          Steffen Seckler added a comment - - edited

          ok, just saying that it would be nice for the more inexperienced users to have an easy option to add these limitations.

          Fyi: got the raw input working with:

          spec:
            serviceAccount: nvidia-deviceplugin
            serviceAccountName: nvidia-deviceplugin
            containers:
              - name: cuda-10
                image: "nvidia/cuda:10.0-devel-centos7"
                env:
                  - name: NVIDIA_VISIBLE_DEVICES
                    value: all
                  - name: NVIDIA_DRIVER_CAPABILITIES
                    value: "compute,utility"
                  - name: NVIDIA_REQUIRE_CUDA
                    value: "cuda>=5.0"
                  - name: HOME
                    value: /home/jenkins
                tty: true
                args:
                  - cat
                command:
                  - /bin/bash
                  - -i
                  - -c
                securityContext:
                  privileged: true
                resources:
                  limits:
                    nvidia.com/gpu: 1 # requesting 1 GPU
          

          especially the tty+command part should not be forgotten. Do I actually need to infuse the jenkins secrets somehow? or are they only relevant for the default (jnlp) container?

          Steffen Seckler added a comment - - edited ok, just saying that it would be nice for the more inexperienced users to have an easy option to add these limitations. Fyi: got the raw input working with: spec: serviceAccount: nvidia-deviceplugin serviceAccountName: nvidia-deviceplugin containers: - name: cuda-10 image: "nvidia/cuda:10.0-devel-centos7" env: - name: NVIDIA_VISIBLE_DEVICES value: all - name: NVIDIA_DRIVER_CAPABILITIES value: "compute,utility" - name: NVIDIA_REQUIRE_CUDA value: "cuda>=5.0" - name: HOME value: /home/jenkins tty: true args: - cat command: - /bin/bash - -i - -c securityContext: privileged: true resources: limits: nvidia.com/gpu: 1 # requesting 1 GPU especially the tty+command part should not be forgotten. Do I actually need to infuse the jenkins secrets somehow? or are they only relevant for the default (jnlp) container?

            Unassigned Unassigned
            seckler Steffen Seckler
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: