Jenkins Kubernetes Agent Pod Templates¶
In a Jenkins deployment running on Kubernetes, Agent Pod Templates define the specifications for the pods that Jenkins launches to execute build jobs^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]. These templates determine the container images, resources, and environment settings available to the Jenkins agent during a build.
Configuration Overview¶
The configuration for these templates is typically managed via the Kubernetes plugin or Helm chart values^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]. Key configuration areas include:
- Pod Configuration: Defines the agent's connection method, idle timeout, and inheritance strategies^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
- Container Configuration: Specifies the JNLP (Java Network Launch Protocol) sidecar image, arguments, and resource limits^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
Key Parameters¶
Pod Settings¶
- Connection: Agents can communicate via WebSockets if enabled (
agent.websocket)^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]. - Idle Minutes: The
idleMinutesparameter allows a pod to remain active for a specified duration after a build completes, allowing for reuse before termination^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]. - YAML Merge Strategy: The
agent.yamlMergeStrategy(default:override) determines how raw YAML definitions are merged with inherited pod templates^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]. - Workspace Volume: By default, the workspace volume is an
EmptyDir, but this can be customized usingagent.workspaceVolume^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
container Settings¶
- Sidecar Image: The default side container is named
jnlpand uses thejenkins/inbound-agentimage^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]. - Command Arguments: The default arguments passed to the agent container are typically
${computer.jnlpmac} ${computer.name}, though these can be overridden^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]. - Resources: CPU and memory requests and limits can be configured to manage the agent's resource consumption^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
- Working Directory: The default working directory for the agent is
/home/jenkins/agent^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
Advanced Configuration¶
Additional Containers¶
Templates can include multiple containers. The agent.additionalContainers parameter allows users to define extra containers (e.g., for tools like Docker, kubectl, or specific language runtimes) within the same agent pod^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
Multiple Templates (Pod Templates)¶
While a default agent configuration exists, users can define specific, named templates for different job requirements^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]. This is configured via:
* agent.podTemplates: Configures extra pod templates for the default Kubernetes cloud^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
* additionalAgents: Defines additional agents that inherit values from the main agent configuration^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
Direct YAML¶
For highly customized needs, agent.yamlTemplate allows the injection of a raw Pod API Object YAML that gets merged into the agent specification^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md].
Related Concepts¶
- Jenkins
- Kubernetes
- [[Pipeline as Code]]
Sources¶
^[400-devops__06-Kubernetes__devops-helm__helm-jenkins__VALUES_SUMMARY.md]