helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

Persist job folder only

Open jgournet opened this issue 3 years ago • 9 comments

Is your feature request related to a problem? Please describe. I would like my jenkins to persist the $JENKINS_HOME/jobs folder, so I can bake everything else into a base image (ie: all my credentials, plugins ...etc would be baked into a docker image). That way, I can get:

  • a fast start of jenkins (no initialization needed)
  • I can even avoid version controlling the plugins: just bake the latest version, and if it fails, use a previous image.
  • any changes done manually will be wiped clean (like installing a new plugin or adding a new credential or whatever ...)

Describe the solution you'd like In essence, we could maybe just add an option here: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/jenkins-controller-statefulset.yaml#L120 , something like:

          volumeMounts:
            {{- if .Values.controller.persistJobsOnly }}
            - mountPath: {{ .Values.controller.jenkinsHome }}/jobs
            {{- else }}
            - mountPath: {{ .Values.controller.jenkinsHome }}
            {{- end }}
              name: jenkins-home

and then add that option "controller.persistJobsOnly" as a false value by default in values.yaml

Describe alternatives you've considered The only other solution I can think of (disclaimer: I'm just starting with this helm chart) would be to modify the init script to wipe off the jenkins home folder except jobs folder, and copy back from the baked image. But that's ugly, and can't even be done easily since the init script does not have a "insert custom script here" (might be a nice to have too ?)

Additional context I know it can be done for the plugins folder by having the plugins in the image in jenkinsRef folder, and playing with the controller.overwritePlugins and controller.installPlugins variables - but that's only for plugins: I'd like to have that simple new option so that we only persist the jobs folder, and nothing else.

I hope I'm clear enough and that it's not a silly request ;)

jgournet avatar Apr 14 '21 04:04 jgournet

Quick update: I actually found out I can accomplish what I need by:

  • setting persistence.enabled to false
  • creating myself the mounts:
persistence.volumes:
- name: jenkins-jobs
  persistentVolumeClaim:
    claimName: myclaim
persistence.mounts:
- name: jenkins-jobs
  mountPath: /var/jenkins_home/jobs
# and for "complete-ish" documentation, those flags are needed as well to use the plugins from the image
controller.installPlugins = []
controller.overwritePluginsFromImage = ""
controller.overwritePlugins = true

So technically, that means this ticket could be closed - but this feels like a workaround/hack, while my proposition would make it a bit cleaner, I think => keeping it open for now

jgournet avatar Apr 15 '21 04:04 jgournet

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Jun 16 '21 23:06 stale[bot]

This functionality would be helpful and goes hand-in-hand with overall recommendation to manage all configurations as code and to create custom image with your plugins. Other than the build logs and job stats, we don't really care about the rest of the files.

pashcan avatar Jun 22 '21 09:06 pashcan

@jgournet out of curiosity, is there any particular reason why you set controller.overwritePluginsFromImage that way instead of using false?

pashcan avatar Jun 22 '21 09:06 pashcan

@pashcan : "yes", there is a reason ... but I kind of forgot :/ So, from bad memory: using false gets me a helm templating error (sorry, that's not super helpful, and we stopped the project, so I can't try again anymore without resurrecting the whole thing :) )

jgournet avatar Jun 22 '21 22:06 jgournet

@jgournet No worries whatsoever! There are so many permutations with different versions of the helm chart and how built-in templates parse and apply certain values... I'll take any insight on what had worked in the past :stuck_out_tongue_closed_eyes: I appreciate you taking the time to reply :pray:

pashcan avatar Jun 23 '21 06:06 pashcan

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Aug 22 '21 18:08 stale[bot]

This would still be useful => not stale

jgournet avatar Nov 15 '21 21:11 jgournet

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 10:04 stale[bot]