Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/jenkins] Support Multiple Kubernetes podTemplates #20870

Closed
orkiguazio opened this issue Feb 19, 2020 · 6 comments · Fixed by #21672 · May be fixed by wmcdona89/charts#2
Closed

[stable/jenkins] Support Multiple Kubernetes podTemplates #20870

orkiguazio opened this issue Feb 19, 2020 · 6 comments · Fixed by #21672 · May be fixed by wmcdona89/charts#2

Comments

@orkiguazio
Copy link

Is your feature request related to a problem? Please describe.
Currently there's no way (that I'm aware of) to create more than one k8s podTemplate (agent.yamlTemplate).

Describe the solution you'd like
Something like:
in tempaltes/config.yaml:

{{- if .Values.agent.enabled }}
  {{- range .Values.agent.podTemplates }}
            <org.csanchez.jenkins.plugins.kubernetes.PodTemplate>
.....
  {{- end }}
{{- end }}

And then in values.yaml:

agent:
    enabled: True
    ...
    ...
    podTemplates:
    - name: tempate1
      yamlTemplate: RAW_YAML1
    - name: template2
      yamlTemplate: RAW_YAML2

Describe alternatives you've considered
None that I can think of..

Additional context
.

@stale
Copy link

stale bot commented Mar 20, 2020

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 stale bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 20, 2020
@wmcdona89
Copy link
Collaborator

I'm working on changes to allow multiple agents to be defined via JCasC. See wmcdona89#2. I don't plan to provide support for xml configuration.

@stale stale bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 21, 2020
@lgg42
Copy link
Contributor

lgg42 commented Mar 29, 2020

Funny, seems like we've been working in the same thing wmcdona89:
#21671

Your PR seems more complete.

@wmcdona89
Copy link
Collaborator

wmcdona89 commented Mar 29, 2020

@lgg42 Thanks for pointing out your PR. I hadn't noticed it yesterday. I think our PRs are complimentary. Yours is pretty straightforward in allowing a user to add podTemplates to the default casc. I'm attempting to abstract away the kubernetes podTemplate casc but I'm realizing now I failed to abstract away the rest of the kubernetes casc so the user still ends up having to know many of the casc details. Perhaps I could make a change similar to yours and add an additionalAgents which would get included in the jenkins.casc.defaults template. Or I could move the kubernetes config to another template and leave it up to the user to include the desired templates in their JCasC similar to what I have currently. A deciding factor might be the extent to which the jenkins.casc.defaults template supports the majority of users or if it's a sane default but most users end up writing their own entire JCasC. I don't have a good sense of this. Let me know if you have any thoughts on any of this.

@lgg42
Copy link
Contributor

lgg42 commented Mar 30, 2020

@wmcdona89 about

I'm realizing now I failed to abstract away the rest of the kubernetes casc so the user still ends up having to know many of the casc details

I want to correctly understand your thought. You meant that maybe there are more fields for the pod templates that your PR is not taking into account? if this is the case... let me attach a real example of a pod template we'd use (the one in my PR is a simple example)

      - containers:
        - args: "cat"
          command: "/bin/sh -c"
          image: "privaterepo.tld/builder-scala:tag"
          name: "scala"
          privileged: true
          resourceLimitCpu: "1"
          resourceLimitMemory: "1024Mi"
          resourceRequestCpu: "400m"
          resourceRequestMemory: "512Mi"
          ttyEnabled: true
          workingDir: "/home/jenkins"
        envVars:
        - containerEnvVar:
            key: "DOCKER_CONFIG"
            value: "/home/jenkins/.docker/"
        - containerEnvVar:
            key: "GIT_AUTHOR_NAME"
            value: "jenkins-bot"
        - containerEnvVar:
            key: "GIT_COMMITTER_EMAIL"
            value: "[email protected]"
        - containerEnvVar:
            key: "GIT_COMMITTER_NAME"
            value: "jenkins-bot"
        - containerEnvVar:
            key: "JENKINS_URL"
            value: "http://jenkins:8080"
        - containerEnvVar:
            key: "XDG_CONFIG_HOME"
            value: "/home/jenkins"
        - containerEnvVar:
            key: "_JAVA_OPTIONS"
            value: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap\
              \ -Dsun.zip.disableMemoryMapping=true -XX:+UseParallelGC -XX:MinHeapFreeRatio=5\
              \ -XX:MaxHeapFreeRatio=10 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90\
              \ -Xms10m -Xmx192m"
        label: "jenkins-scala"
        name: "scala"
        serviceAccount: "jenkins"
        slaveConnectTimeoutStr: "0"
        volumes:
        - hostPathVolume:
            hostPath: "/var/run/docker.sock"
            mountPath: "/var/run/docker.sock"
        - secretVolume:
            mountPath: "/home/jenkins/.docker"
            secretName: "jenkins-docker-cfg"
        yamlMergeStrategy: "override"

Like that one, we have like 10, context: we're coming from JenkinsX which have by default a lot of pod templates. That's why if we want to use the stable/jenkins chart for our pipelines we need to have a set of pre-defined custom pod templates.

About:

A deciding factor might be the extent to which the jenkins.casc.defaults template supports the majority of users or if it's a sane default but most users end up writing their own entire JCasC

I'm also lacking a good sense on that. The default config works perfect for me. and I think JenkinsX sticks to this same default config, except they add extra the pod templates

About your change proposal, I'd personally stick with adding an additionalAgents value which would get included in the jenkins.casc.defaults template. Anything about moving the kubernetes config to another template I'd leave it to another PR, just for simplicity.

If you decide to go with that previous approach I'd be happy to close my PR in favor of yours. Anyway I think we can definitely find common ground here. Great work! 💪

@wmcdona89
Copy link
Collaborator

Thanks for the insight! I updated my PR to use the default casc. Definitely simplified the usage. Let me know how it works for you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants