Skip to content

Commit 8108913

Browse files
authored
Allow to scale to zero via helm values (#1627)
1 parent 9a5e60d commit 8108913

7 files changed

Lines changed: 359 additions & 315 deletions

File tree

charts/jenkins/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Use the following links to reference issues, PRs, and commits prior to v2.6.0.
1212
The changelog until v1.5.7 was auto-generated based on git commits.
1313
Those entries include a reference to the git commit to be able to get more details.
1414

15+
## 5.9.3
16+
17+
Allow to scale controller to zero replicas during maintenance scenarios.
18+
1519
## 5.9.2
1620

1721
Add support for annotations on the HTTPRoute resource

charts/jenkins/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: jenkins
33
type: application
44
home: https://www.jenkins.io/
5-
version: 5.9.2
5+
version: 5.9.3
66
appVersion: 2.541.2
77
description: >
88
Jenkins - Build great things at any scale! As the leading open source automation server, Jenkins provides over 2000 plugins to support building, deploying and automating any project.

charts/jenkins/VALUES.md

Lines changed: 314 additions & 313 deletions
Large diffs are not rendered by default.

charts/jenkins/templates/_helpers.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,3 +714,11 @@ Create the HTTP port for interacting with the controller
714714
{{- end }}
715715

716716
{{- end -}}
717+
718+
{{- define "controller.replicas" -}}
719+
{{- $replicas := int (default 1 .Values.controller.replicas) -}}
720+
{{- if or (lt $replicas 0) (gt $replicas 1) -}}
721+
{{- fail "controller.replicas must be 0 or 1" -}}
722+
{{- end -}}
723+
{{- .Values.controller.replicas -}}
724+
{{- end -}}

charts/jenkins/templates/jenkins-controller-statefulset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ metadata:
1818
{{- end }}
1919
spec:
2020
serviceName: {{ template "jenkins.fullname" . }}
21-
replicas: 1
21+
replicas: {{ include "controller.replicas" . }}
2222
selector:
2323
matchLabels:
2424
"app.kubernetes.io/component": "{{ .Values.controller.componentName }}"

charts/jenkins/unittests/jenkins-controller-statefulset-test.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,3 +840,30 @@ tests:
840840
renderHelmLabels: false
841841
asserts:
842842
- matchSnapshot: {}
843+
- it: fails when replicas is greater than 1
844+
template: jenkins-controller-statefulset.yaml
845+
set:
846+
controller:
847+
replicas: 2
848+
asserts:
849+
- failedTemplate:
850+
errorPattern:
851+
'controller.replicas must be 0 or 1'
852+
- it: allow to scale to 0 replicas
853+
template: jenkins-controller-statefulset.yaml
854+
set:
855+
controller:
856+
replicas: 0
857+
asserts:
858+
- equal:
859+
path: spec.replicas
860+
value: 0
861+
- it: allow to scale to 1 replicas
862+
template: jenkins-controller-statefulset.yaml
863+
set:
864+
controller:
865+
replicas: 1
866+
asserts:
867+
- equal:
868+
path: spec.replicas
869+
value: 1

charts/jenkins/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ controller:
5151
tagLabel: jdk21
5252
# -- Controller image pull policy
5353
pullPolicy: "Always"
54+
55+
# -- Number of replicas. Max 1. Can be set to 0 for maintenance scenarios.
56+
replicas: 1
57+
5458
# -- Controller image pull secret
5559
imagePullSecretName:
5660
# -- Lifecycle specification for controller-container

0 commit comments

Comments
 (0)