Resource limits for Kubernetes builds

Hello!

I’m configuring self-managed GitLab with K8s runner. I want to limit the resources for CI/CD jobs. I’ve read the documentation and the article and found that it’s possible to set requests and limits for all jobs with cpu_limit and momory_limit. These values will be used for Pod creation. It’s also possible to set limits for each service in the services section of .gitlab-ci.yml. I can define the maximum number of concurrent jobs with concurrent option.

Unfortunately, there is a problem: E.g. I have concurrent = 2, 2Gb RAM and 2CPU for the Kubernetes runner. I have a project that consumes 1Gb RAM and 1CPU for one job. It has such .gitlab-ci.yml:

default:
  before_script:
    - bundle install

test:
  image: ruby:2.6
  script:
    - bundle exec rake spec

It’s possible to run 2 builds concurrently, but when I add a service like this:

default:
  before_script:
    - bundle install

test:
  image: ruby:2.6
  services:
    - postgres:11.7
  script:
    - bundle exec rake spec

The first build starts correctly but for the second I have an error about resource limits:

ERROR: Job failed (system failure): prepare environment: pods "runner-yc3ywhza-project-208-concurrent-089f4x" is forbidden: exceeded quota: gitlab-runners-prod-quota. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

I think the reason for the error is that the build consumes more resources than 1Gb RAM and 1CPU because of postgresql service, so the second build can’t start.

How can I limit resources for one job? I want all containers of one job to consume no more 1Gb of RAM no matter how many services were defined in .gitlab-ci.yml? In the example above I want the job either to start without errors or to wait in the queue without resource errors.