From e4d8a179d92cb98a66cc4ab8b125dc7129f02882 Mon Sep 17 00:00:00 2001 From: Aaron McDonald Date: Fri, 24 Apr 2020 01:24:07 -0400 Subject: [PATCH] [stable/jenkins] Add support for PVC in agent.volumes (#22048) Signed-off-by: Aaron McDonald --- stable/jenkins/CHANGELOG.md | 4 ++++ stable/jenkins/Chart.yaml | 2 +- stable/jenkins/README.md | 2 +- stable/jenkins/templates/_helpers.tpl | 13 +++++++++++-- stable/jenkins/templates/config.yaml | 2 +- stable/jenkins/values.yaml | 6 +++++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/stable/jenkins/CHANGELOG.md b/stable/jenkins/CHANGELOG.md index 5755e47759..f53921d97f 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.17.1 + +Add support for Persistent Volume Claim (PVC) in `agent.volumes` + ## 1.17.0 Render `agent.volumes` in kubernetes pod template JCasC diff --git a/stable/jenkins/Chart.yaml b/stable/jenkins/Chart.yaml index 68265532af..fed6089aaf 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.17.0 +version: 1.17.1 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 e8a19b0be2..3c284cd573 100644 --- a/stable/jenkins/README.md +++ b/stable/jenkins/README.md @@ -248,7 +248,7 @@ agent: mountPath: /var/run/secrets/jenkins-mysecrets ``` -The supported volume types are: `ConfigMap`, `EmptyDir`, `HostPath`, `Nfs`, `Pod`, `Secret`. Each type supports a different set of configurable attributes, defined by [the corresponding Java class](https://github.com/jenkinsci/kubernetes-plugin/tree/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes). +The supported volume types are: `ConfigMap`, `EmptyDir`, `HostPath`, `Nfs`, `PVC`, `Secret`. Each type supports a different set of configurable attributes, defined by [the corresponding Java class](https://github.com/jenkinsci/kubernetes-plugin/tree/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes). ## NetworkPolicy diff --git a/stable/jenkins/templates/_helpers.tpl b/stable/jenkins/templates/_helpers.tpl index 8b37bd8a42..2b8361d289 100644 --- a/stable/jenkins/templates/_helpers.tpl +++ b/stable/jenkins/templates/_helpers.tpl @@ -185,6 +185,7 @@ Returns kubernetes pod template configuration as code {{- else if (eq $volume.type "EmptyDir") }} emptyDirVolume: {{- else if (eq $volume.type "HostPath") }} hostPathVolume: {{- else if (eq $volume.type "Nfs") }} nfsVolume: + {{- else if (eq $volume.type "PVC") }} persistentVolumeClaim: {{- else if (eq $volume.type "Secret") }} secretVolume: {{- else }} {{ $volume.type }}: {{- end }} @@ -225,11 +226,19 @@ Returns kubernetes pod template xml configuration NORMAL {{- range $index, $volume := .Values.agent.volumes }} + {{- if (eq $volume.type "PVC") }} + + {{- else }} -{{- range $key, $value := $volume }}{{- if not (eq $key "type") }} + {{- end }} + {{- range $key, $value := $volume }}{{- if not (eq $key "type") }} <{{ $key }}>{{ $value }} -{{- end }}{{- end }} + {{- end }}{{- end }} + {{- if (eq $volume.type "PVC") }} + + {{- else }} + {{- end }} {{- end }} diff --git a/stable/jenkins/templates/config.yaml b/stable/jenkins/templates/config.yaml index 01be3f5f38..b357922b40 100644 --- a/stable/jenkins/templates/config.yaml +++ b/stable/jenkins/templates/config.yaml @@ -61,7 +61,7 @@ data: {{- /* restore .Values.agent */}} {{- $_ := set .Values "agent" $agent }} {{- end }} -{{- end -}} +{{- end }} https://kubernetes.default false diff --git a/stable/jenkins/values.yaml b/stable/jenkins/values.yaml index 6ab24ef64b..c905c1c4dd 100644 --- a/stable/jenkins/values.yaml +++ b/stable/jenkins/values.yaml @@ -436,7 +436,7 @@ agent: # Possible values: Always, Never, OnFailure podRetention: "Never" # You can define the volumes that you want to mount for this container - # Allowed types are: ConfigMap, EmptyDir, HostPath, Nfs, Pod, Secret + # Allowed types are: ConfigMap, EmptyDir, HostPath, Nfs, PVC, Secret # Configure the attributes as they appear in the corresponding Java class for that type # https://github.com/jenkinsci/kubernetes-plugin/tree/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes volumes: [] @@ -454,6 +454,10 @@ agent: # readOnly: false # serverAddress: "192.0.2.0" # serverPath: /var/lib/containers + # - type: PVC + # claimName: mypvc + # mountPath: /var/myapp/mypvc + # readOnly: false # - type: Secret # defaultMode: "600" # mountPath: /var/myapp/mysecret