Skip to content

Commit

Permalink
Add UserContent mechanism
Browse files Browse the repository at this point in the history
Signed-off-by: Timm Drevensek <[email protected]>
  • Loading branch information
timmjd committed Aug 3, 2022
1 parent f6a406e commit e360ba2
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 1 deletion.
4 changes: 4 additions & 0 deletions charts/jenkins/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion charts/jenkins/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
15 changes: 15 additions & 0 deletions charts/jenkins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
13 changes: 13 additions & 0 deletions charts/jenkins/templates/jenkins-controller-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions charts/jenkins/templates/secret-usercontent.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
5 changes: 5 additions & 0 deletions charts/jenkins/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e360ba2

Please sign in to comment.