Skip to content

Commit 4544e94

Browse files
authored
[jenkins] Update readme (#38)
Signed-off-by: Reinhard Nägele <[email protected]>
1 parent fb8f67c commit 4544e94

File tree

4 files changed

+81
-4
lines changed

4 files changed

+81
-4
lines changed

charts/jenkins/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
name: jenkins
33
description: The leading open source automation server
4-
version: 1.3.0
4+
version: 1.3.1
55
appVersion: 2.164.3
66
home: https://jenkins.io/
77
icon: https://wiki.jenkins-ci.org/download/attachments/2916393/logo.png

charts/jenkins/README.md

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Parameter | Description | Default
4949
`extraVolumeMounts` | Add additional volumes mounts. Passed through the `tpl` function and thus to be configured as string | `""`
5050
`extraVolumes` | Add additional volumes. Passed through the `tpl` function and thus to be configured as string | `""`
5151
`podAnnotations` | Annotations for the Jenkins pod | `{}`
52-
`javaOpts` | `JAVA_OPTS` for the Jenkins process | `-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2 -XshowSettings:vm`
52+
`javaOpts` | `JAVA_OPTS` for the Jenkins process | see below and `values.yaml` for defaults
5353
`extraEnv` | Allows the specification of additional environment variables for Jenkins. Passed through the `tpl` function and thus to be configured as string | `""`
5454
`livenessProbe` | Liveness probe configuration | see `values.yaml` for defaults
5555
`readinessProbe` | Readiness probe configuration | see `values.yaml` for defaults
@@ -118,6 +118,10 @@ By default, the following `JAVA_OPTS` are configured as environment variable:
118118

119119
```yaml
120120
javaOpts: >-
121+
-Dhudson.slaves.NodeProvisioner.initialDelay=0
122+
-Dhudson.model.LoadStatistics.decay=0.7
123+
-Dhudson.slaves.NodeProvisioner.MARGIN=30
124+
-Dhudson.slaves.NodeProvisioner.MARGIN0=0.6
121125
-XX:+UnlockExperimentalVMOptions
122126
-XX:+UseCGroupMemoryLimitForHeap
123127
-XX:MaxRAMFraction=2
@@ -128,6 +132,10 @@ This allows the JVM to be configured using memory settings for the container.
128132
By default, the JVM uses 50 % of the container's available memory.
129133
Note that the JVM will also need off-heap memory.
130134
135+
Agent provisioning can be configured with a set of system properties.
136+
137+
### Resources
138+
131139
Resource requests and limits should be configured.
132140
If your Jenkins JVM should get 1 GiB of max. heap, the container should be set to 2 GiB.
133141
@@ -197,13 +205,13 @@ The file must list the plugins to be installed.
197205
Versions are optional and must be delimited by a colon.
198206
Since it may not be desirable that plugins are updated when the pod is restarted, the Helm chart implements the following logic:
199207

200-
![plugins state diagram](assets/plugins.png)
208+
![plugins state diagram](plugins.png)
201209

202210

203211
It is advisable to use an LTS version of Jenkins.
204212
LTS versions have their own update centers with compatible plugin versions only.
205213
Don't specify versions in order to get the latest compatible versions.
206-
In order to avoid unexpected plugin updates in case the pod is rescheduled, set `forcePluginsUpdates` to `false`, which is the default, and only set it to `true` temporarily in order to update plugins.
214+
In order to avoid unexpected plugin updates in case the pod is rescheduled, set `forcePluginUpdates` to `false`, which is the default, and only set it to `true` temporarily in order to update plugins.
207215

208216
#### Configuration as Code
209217

@@ -387,3 +395,72 @@ However, if your Jenkins Master or any of the agents need to access the Kubernet
387395

388396
The chart allows configuring ServiceAccounts and RBAC resources for the master as well as for any agents.
389397
ServiceAcounts for agents can then be assigned in pod templates.
398+
399+
### Updating Java's Truststore
400+
401+
In order to add a certificate to the truststore, we can copy it to a different location, add the certificate, and configure Java to use the updated truststore.
402+
403+
You need to create a configmap containing the certificate.
404+
This has to be done upfront and is not part of the Helm chart.
405+
406+
```console
407+
kubectl create configmap my-cert-configmap --from-file=my-ca.cer --dry-run --output yaml | kubectl apply -f -
408+
```
409+
410+
Next, we need an init-container that mounts the configmap, `JENKINS_HOME`, and a shared empty dir that's also mounted into the Jenkins container.
411+
The shared dir will contain the updated truststore.
412+
A shell script that's added as reference content is executed in the init container and performs the truststore update.
413+
The path to the new truststore is added as system property.
414+
415+
```yaml
416+
referenceContent:
417+
- relativeDir: custom-init-scripts
418+
defaultMode: 0555
419+
data:
420+
- fileName: truststore.sh
421+
fileContent: |
422+
#!/usr/bin/env bash
423+
424+
echo 'Adding CA certificate to Java truststore...'
425+
cd /etc/jenkins_ca/truststore
426+
cp /etc/ssl/certs/java/cacerts .
427+
chmod 666 /etc/jenkins_ca/truststore/cacerts
428+
keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias my-ca -file ../my-ca/my-ca.cer
429+
chmod 444 /etc/jenkins_ca/truststore/cacerts
430+
431+
extraInitContainers: |
432+
- name: jenkins-truststore-init
433+
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
434+
imagePullPolicy: {{ .Values.image.pullPolicy }}
435+
command:
436+
- /var/jenkins_home/custom-init-scripts/truststore.sh
437+
volumeMounts:
438+
- name: jenkins-home
439+
mountPath: /var/jenkins_home
440+
- name: my-ca
441+
mountPath: /etc/jenkins_ca/my-ca
442+
- name: truststore
443+
mountPath: /etc/jenkins_ca/truststore
444+
445+
extraVolumeMounts: |
446+
- name: truststore
447+
mountPath: /etc/jenkins_ca/truststore
448+
449+
extraVolumes: |
450+
- name: my-ca
451+
configMap:
452+
name: my-ca
453+
- name: truststore
454+
emptyDir: {}
455+
456+
javaOpts: >-
457+
-Dhudson.slaves.NodeProvisioner.initialDelay=0
458+
-Dhudson.model.LoadStatistics.decay=0.7
459+
-Dhudson.slaves.NodeProvisioner.MARGIN=30
460+
-Dhudson.slaves.NodeProvisioner.MARGIN0=0.6
461+
-XX:+UnlockExperimentalVMOptions
462+
-XX:+UseCGroupMemoryLimitForHeap
463+
-XX:MaxRAMFraction=2
464+
-XshowSettings:vm
465+
-Djavax.net.ssl.trustStore=/etc/jenkins_ca/truststore/cacerts
466+
```
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)