Kubernetes builds using too many resources

I am trying to set resource limits and requests because I am having issues where builds are taking up too many resources on some nodes and causing pods to crash. However the problem I am facing is if I have 10 steps to my build and I set cpu requests to ‘1’ it tries to allocate all the cpu’s for all the steps at the same time even though each step should only need the resource when it is actually running. So it requests 10 cpus instead of 1 at a time, which basically makes the feature unusable.

Are you using an older release of the Kubernetes runner?

Resource requests are no longer defined per step, they are defined per-pipeline (see below example) which solves the problem you are describing. More background in this thread.

kind: pipeline
type: kubernetes
name: default

    cpu: 1
    memory: 2000MiB

steps: ...

Ah yes I hadn’t updated in a while… Looks perfect, cool!

So I upgraded Drone to 2.4.0 and Runner to 1.0.0-beta.12 and I am seeing this error when I put the limits as you show above:

EDIT: nvm, looks like it only supports requests and not limits.

Does the environment variable DRONE_RESOURCE_REQUEST_CPU now apply this to all builds in this way?

I recommend using the latest release which is 1.0.0-rc.2

In terms of the resource environment variables, this is not an area I have a ton of expertise and I don’t want to misspeak, so I recommend checking out this document:

cc @marko-gacesa if you have any follow up questions