From e360ba2dddd09d0c6e35abedffced7eabfbf465c Mon Sep 17 00:00:00 2001 From: Timm Drevensek <508684+timmjd@users.noreply.github.com> Date: Wed, 3 Aug 2022 19:57:01 +0200 Subject: [PATCH] Add UserContent mechanism Signed-off-by: Timm Drevensek <508684+timmjd@users.noreply.github.com> --- charts/jenkins/CHANGELOG.md | 4 ++++ charts/jenkins/Chart.yaml | 2 +- charts/jenkins/README.md | 15 +++++++++++++ .../jenkins-controller-statefulset.yaml | 13 ++++++++++++ .../jenkins/templates/secret-usercontent.yaml | 21 +++++++++++++++++++ charts/jenkins/values.yaml | 5 +++++ 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 charts/jenkins/templates/secret-usercontent.yaml diff --git a/charts/jenkins/CHANGELOG.md b/charts/jenkins/CHANGELOG.md index eb69a8d01..e2846aaef 100644 --- a/charts/jenkins/CHANGELOG.md +++ b/charts/jenkins/CHANGELOG.md @@ -12,6 +12,10 @@ Use the following links to reference issues, PRs, and commits prior to v2.6.0. The change log until v1.5.7 was auto-generated based on git commits. Those entries include a reference to the git commit to be able to get more details. +## 4.1.15 + +Add option to add custom data via `controller.userContents` that will be hosted by the Server. + ## 4.1.14 If `installPlugins` is disabled, don't create unused plugins volume. diff --git a/charts/jenkins/Chart.yaml b/charts/jenkins/Chart.yaml index 1d14bd3ec..d04b39aef 100644 --- a/charts/jenkins/Chart.yaml +++ b/charts/jenkins/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: jenkins home: https://jenkins.io/ -version: 4.1.14 +version: 4.1.15 appVersion: 2.346.2 description: Jenkins - Build great things at any scale! The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project. sources: diff --git a/charts/jenkins/README.md b/charts/jenkins/README.md index de8103856..b5afbb5e3 100644 --- a/charts/jenkins/README.md +++ b/charts/jenkins/README.md @@ -410,6 +410,21 @@ controller: renew: 60 ``` +### User Content + +The [User Content](https://www.jenkins.io/doc/book/managing/user-content/) mechanism allows to use the Jenkins server to host custom files under the `/userContent` prefix. + +```yaml +controller: + userContents: + - name: foobar.txt + path: SGVsbG8gV29ybGQ= # Hello World +``` + +Will provide the content `Hello World` via the `http(s)://jenkins.example.com/userContent/foobar.txt` URL. + +Be aware that ConfigMaps & Secrets are __limited to 1 MB__ in Kubernetes. Also the content must be __base64 encoded__ to be capable to provide binary content like a PNG image. + ### RBAC RBAC is enabled by default. If you want to disable it you will need to set `rbac.create` to `false`. diff --git a/charts/jenkins/templates/jenkins-controller-statefulset.yaml b/charts/jenkins/templates/jenkins-controller-statefulset.yaml index 5069e29e9..ecb630ea4 100644 --- a/charts/jenkins/templates/jenkins-controller-statefulset.yaml +++ b/charts/jenkins/templates/jenkins-controller-statefulset.yaml @@ -288,6 +288,14 @@ spec: mountPath: /run/secrets/additional readOnly: true {{- end }} + {{- if or .Values.controller.userContents }} + {{- range $key, $value := .Values.controller.userContents }} + - name: jenkins-user-contents + mountPath: {{ $.Values.controller.jenkinsHome }}/userContent/{{ $value.name }} + subPath: {{ $value.name }} + readOnly: true + {{- end }} + {{- end }} - name: jenkins-cache mountPath: /var/jenkins_cache - mountPath: /tmp @@ -425,6 +433,11 @@ spec: - key: jenkins-jks-file path: {{ .Values.controller.httpsKeyStore.fileName }} {{- end }} + {{- if .Values.controller.userContents }} + - name: jenkins-user-contents + secret: + secretName: {{ template "jenkins.fullname" . }}-user-contents + {{- end }} {{- if .Values.controller.imagePullSecretName }} imagePullSecrets: diff --git a/charts/jenkins/templates/secret-usercontent.yaml b/charts/jenkins/templates/secret-usercontent.yaml new file mode 100644 index 000000000..386e59d21 --- /dev/null +++ b/charts/jenkins/templates/secret-usercontent.yaml @@ -0,0 +1,21 @@ +{{- if .Values.controller.userContents -}} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "jenkins.fullname" . }}-user-contents + namespace: {{ template "jenkins.namespace" . }} + labels: + "app.kubernetes.io/name": '{{ template "jenkins.name" .}}' + {{- if .Values.renderHelmLabels }} + "helm.sh/chart": "{{ template "jenkins.label" .}}" + {{- end }} + "app.kubernetes.io/managed-by": "{{ .Release.Service }}" + "app.kubernetes.io/instance": "{{ .Release.Name }}" + "app.kubernetes.io/component": "{{ .Values.controller.componentName }}" +type: Opaque +data: +{{- range .Values.controller.userContents }} + {{ .name }}: {{ .value }} +{{- end }} +{{- end }} diff --git a/charts/jenkins/values.yaml b/charts/jenkins/values.yaml index 9156743f6..8bb4c5226 100644 --- a/charts/jenkins/values.yaml +++ b/charts/jenkins/values.yaml @@ -338,6 +338,11 @@ controller: # imagePullPolicy: Always # command: [ "uname", "-a" ] + # Provide files that will be served by the Jenkins via the User Content mechanism + userContents: [] + # - name: filename + # value: file content in base64 encoding + sidecars: configAutoReload: # If enabled: true, Jenkins Configuration as Code will be reloaded on-the-fly without a reboot. If false or not-specified,