Skip to content

Kubernetes Jenkins resource allocation best practices

When deploying Jenkins within a Kubernetes cluster, it is critical to define resource constraints to ensure stability and prevent the container from being terminated due to memory exhaustion.^[400-devops-06-kubernetes-k8s-jenkins-k8s.md]

Resource Requests

For the jenkins/jenkins:lts-alpine image, it is recommended to configure the container with specific resource requests.^[400-devops-06-kubernetes-k8s-jenkins-k8s.md] These settings represent the minimum amount of resources required to run the instance.

  • CPU: 1000m (1 core)
  • Memory: 1Gi

Resource Limits

To prevent the Jenkins controller from monopolizing node resources or crashing due to [[OOMKilled]] errors, resource limits should be set slightly higher than the requests.^[400-devops-06-kubernetes-k8s-jenkins-k8s.md]

  • CPU: 1200m (1.2 cores)
  • Memory: 2Gi

JVM Configuration

The allocated memory limits should correspond with the Java Virtual Machine (JVM) memory settings defined in the JAVA_OPTS environment variable.^[400-devops-06-kubernetes-k8s-jenkins-k8s.md] For the heap size configuration (-Xmx), ensure that the maximum heap size (e.g., -Xmx1024m) remains within the requested memory allocation to allow room for the JVM overhead and the operating system.^[400-devops-06-kubernetes-k8s-jenkins-k8s.md]

Sources

^[400-devops-06-kubernetes-k8s-jenkins-k8s.md]