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

Support for multiple container templates under kubernetes pod template configuration as code

Open psimms-r7 opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe

Allow support to define multiple container templates for the default agent definition

This would allow multiple containers to be defined along side the standard jnlp container

https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/_helpers.tpl#L225

Describe the solution you'd like

Option to pass in multiple container templates to live along side the jnlp container.

Currently there is only an option to define a single container in the default agent template, if we need the default agent pod to have multiple containers in it we need to define this separately and then merge into the default

Describe alternatives you've considered

I currently accomplish this by using "yamlTemplate" to define an additional container, which then gets merged into the default agent

Additional context

The need to allow multiple containers to be defined as part of the default agent template. Main use case for us is to attach a docker:dind container in order for the default agent (custom pre built image) to support docker by default with no need to mount docker socket

Under https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/_helpers.tpl#L225 ("containers:") there is only option for a single container so in the current setup it is not possible to define additional containers as part of this template.

psimms-r7 avatar Mar 28 '22 18:03 psimms-r7

Is this referrign to things like this

pipeline {
  agent {
    kubernetes {
      inheritFrom 'default'
      yamlFile 'automation/Jenkins/KubernetesPod.yaml'
    }
  }

Where KubernetesPod.yaml contains code like

metadata:
  labels:
    job-name: cicd_application
spec:
  containers:
    - name: operations
      image: xxxxx.dkr.ecr.us-west-1.amazonaws.com/operations:0.1.3
      command:
        - sleep
      args:
        - 99d

Then we launch our jobs and do

      steps {
        container('operations') {

because, we are also looking for a way to centralize this. As of now, when the image version bumps, we have to update every single repo's pipeline.

jseiser avatar May 20 '22 16:05 jseiser

Is this referrign to things like this

pipeline {
  agent {
    kubernetes {
      inheritFrom 'default'
      yamlFile 'automation/Jenkins/KubernetesPod.yaml'
    }
  }

Where KubernetesPod.yaml contains code like

metadata:
  labels:
    job-name: cicd_application
spec:
  containers:
    - name: operations
      image: xxxxx.dkr.ecr.us-west-1.amazonaws.com/operations:0.1.3
      command:
        - sleep
      args:
        - 99d

Then we launch our jobs and do

      steps {
        container('operations') {

because, we are also looking for a way to centralize this. As of now, when the image version bumps, we have to update every single repo's pipeline.

No from what I can see you are outlining pod templates as part of a pipeline job which is completely separate to this, I have updated the original issue with bit more info, this is more about helm/config as code creating the default pod template as baked into jenkins.

As for your issue you can centralise pod templates using shared libraries so your pipeline would get from a central source

psimms-r7 avatar May 25 '22 15:05 psimms-r7