diff --git a/stable/jenkins/CHANGELOG.md b/stable/jenkins/CHANGELOG.md index 99bc90d3fc..f5bca522c6 100644 --- a/stable/jenkins/CHANGELOG.md +++ b/stable/jenkins/CHANGELOG.md @@ -5,6 +5,10 @@ numbering uses [semantic versioning](http://semver.org). NOTE: The change log until version 1.5.7 is auto generated based on git commits. Those include a reference to the git commit to be able to get more details. +## 1.11.0 Add support for configuring custom pod templates + +Add `agent.podTemplates` option for declaring custom pod templates in the default configured kubernetes cloud. + ## 1.10.1 Only copy JCasC files if there are any The chart always tried to copy Configuration as Code configs even if there are none. That resulted in an error which is resolved with this. diff --git a/stable/jenkins/Chart.yaml b/stable/jenkins/Chart.yaml index ab4548694b..4d753e5749 100644 --- a/stable/jenkins/Chart.yaml +++ b/stable/jenkins/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: jenkins home: https://jenkins.io/ -version: 1.10.2 +version: 1.11.0 appVersion: lts description: Open source continuous integration server. It supports multiple SCM tools including CVS, Subversion and Git. It can execute Apache Ant and Apache Maven-based diff --git a/stable/jenkins/README.md b/stable/jenkins/README.md index e92c8f7590..50e4a49030 100644 --- a/stable/jenkins/README.md +++ b/stable/jenkins/README.md @@ -216,6 +216,7 @@ Some third-party systems, e.g. GitHub, use HTML-formatted data in their payload | `agent.idleMinutes` | Allows the Pod to remain active for reuse | 0 | | `agent.yamlTemplate` | The raw yaml of a Pod API Object to merge into the agent spec | Not set | | `agent.slaveConnectTimeout`| Timeout in seconds for an agent to be online | 100 | +| `agent.podTemplates` | Configures extra pod templates for the default kubernetes cloud | `{}` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. @@ -482,6 +483,39 @@ master: Docs taken from https://github.com/jenkinsci/docker/blob/master/Dockerfile: _Jenkins is run with user `jenkins`, uid = 1000. If you bind mount a volume from the host or a data container,ensure you use the same uid_ +## Adding custom pod templates +It is possible to add custom pod templates for the default configured kubernetes cloud. +Add a key under `agent.podTemplates` for each pod template. Each key (prior to | character) is just a label, and can be any value. +Keys are only used to give the pod template a meaningful name. The only restriction is they may only contain RFC 1123 \ DNS label +characters: lowercase letters, numbers, and hyphens. Each pod template can contain multiple containers. +There's no need to add the *jnlp* container since the kubernetes plugin will automatically inject it into the pod. +For this pod templates configuration to be loaded the following values must be set: +``` +master.JCasC.enabled: true +master.JCasC.defaultConfig: true +``` +The example below creates a python pod template in the kubernetes cloud. +``` +agent: + podTemplates: + python: | + - name: python + label: jenkins-python + serviceAccount: jenkins + containers: + - name: python + image: python:3 + command: "/bin/sh -c" + args: "cat" + ttyEnabled: true + privileged: true + resourceRequestCpu: "400m" + resourceRequestMemory: "512Mi" + resourceLimitCpu: "1" + resourceLimitMemory: "1024Mi" +``` +Best reference is https:///configuration-as-code/reference#Cloud-kubernetes. + ## Running behind a forward proxy The master pod uses an Init Container to install plugins etc. If you are behind a corporate proxy it may be useful to set `master.initContainerEnv` to add environment variables such as `http_proxy`, so that these can be downloaded. diff --git a/stable/jenkins/ci/casc-values.yaml b/stable/jenkins/ci/casc-values.yaml index 24c2cf94d2..2ca41a1780 100644 --- a/stable/jenkins/ci/casc-values.yaml +++ b/stable/jenkins/ci/casc-values.yaml @@ -1,6 +1,7 @@ master: JCasC: enabled: true + defaultConfig: true sidecars: configAutoReload: enabled: true diff --git a/stable/jenkins/templates/_helpers.tpl b/stable/jenkins/templates/_helpers.tpl index de6f996423..8b2725334a 100644 --- a/stable/jenkins/templates/_helpers.tpl +++ b/stable/jenkins/templates/_helpers.tpl @@ -142,6 +142,11 @@ jenkins: yaml: |- {{ tpl .Values.agent.yamlTemplate . | nindent 10 | trim }} yamlMergeStrategy: "override" + {{- if .Values.agent.podTemplates }} + {{- range $key, $val := .Values.agent.podTemplates }} + {{- tpl $val $ | nindent 6 }} + {{- end }} + {{- end }} {{- end }} {{- if .Values.master.csrf.defaultCrumbIssuer.enabled }} crumbIssuer: diff --git a/stable/jenkins/values.yaml b/stable/jenkins/values.yaml index feba0ed772..8a6b64fbc8 100644 --- a/stable/jenkins/values.yaml +++ b/stable/jenkins/values.yaml @@ -470,6 +470,30 @@ agent: # Timeout in seconds for an agent to be online slaveConnectTimeout: 100 + # Below is the implementation of custom pod templates for the default configured kubernetes cloud. + # Add a key under podTemplates for each pod template. Each key (prior to | character) is just a label, and can be any value. + # Keys are only used to give the pod template a meaningful name. The only restriction is they may only contain RFC 1123 \ DNS label + # characters: lowercase letters, numbers, and hyphens. Each pod template can contain multiple containers. + # For this pod templates configuration to be loaded the following values must be set: + # master.JCasC.enabled: true + # master.JCasC.defaultConfig: true + # Best reference is https:///configuration-as-code/reference#Cloud-kubernetes. The example below creates a python pod template. + podTemplates: {} + # python: | + # - name: python + # label: jenkins-python + # serviceAccount: jenkins + # containers: + # - name: python + # image: python:3 + # command: "/bin/sh -c" + # args: "cat" + # ttyEnabled: true + # privileged: true + # resourceRequestCpu: "400m" + # resourceRequestMemory: "512Mi" + # resourceLimitCpu: "1" + # resourceLimitMemory: "1024Mi" persistence: enabled: true ## A manually managed Persistent Volume and Claim