Configure Kubernetes cpu memory request and limit for a jenkins slaves created with jenkinsci kubernetes-plugin

Viewed 2739

I am using jenkinsci/kubernetes-plugin to provision slave pods in my Jenkins builds. I need to specify these pods' cpu and memory limit and request params. It can be done directly in the pipeline configuration, as shown here.

However I would prefer to do it directly in the Jenkins configuration (Manage Jenkins -> Configure System -> Kubernetes -> Kubernetes Pod Template.

There is a specific section to insert a mergeable raw yaml:

enter image description here

How can it be set up there? I have tried but it didn't seem to work.

2 Answers

I have found and option to configure it hidden under advanced options:

enter image description here

You can set the memory and CPU of your Jenkins agent (JNLP container) via the Kubernetes plugin container template yaml.

To change "resourceLimitCpu" and "resourceLimitMemory" values for example:

  clouds:
  - kubernetes:
      ...
      name: "kubernetes"
      templates:
      - containers:
        - image: "..."
          name: "jnlp"
          resourceLimitCpu: "1000m"
          resourceLimitMemory: "4000Mi"
          ...
Related