Uploaded image for project: 'OpenShift Jenkins'
  1. OpenShift Jenkins
  2. JKNS-257

Use sidecar pattern for Jenkins pod templates

    • 5
    • False
    • False
    • Hide
      In OpenShift Container Platform 4.10, the non-sidecar maven and nodejs pod templates for Jenkins are deprecated. These pod templates are planned for removal in a future release. Bug fixes and support are provided through the end of that future life cycle, after which no new feature enhancements are made. Instead, with this update, you can run Jenkins agents as sidecar containers. (JKNS-257)

      Show
      In OpenShift Container Platform 4.10, the non-sidecar maven and nodejs pod templates for Jenkins are deprecated. These pod templates are planned for removal in a future release. Bug fixes and support are provided through the end of that future life cycle, after which no new feature enhancements are made. Instead, with this update, you can run Jenkins agents as sidecar containers. ( JKNS-257 )
    • Sprint 211, Sprint 212, Sprint 213

      User Story

      As a developer using Jenkins to build my application
      I want to use the base Jenkins agent image as a sidecar in my PodTemplate
      So that I can use any s2i builder image in my Jenkins pipelines

      Acceptance Criteria

      • Provide new Kubernetes Plugin Pod Templates which uses the sidecar pattern for NodeJS and Maven.
      • Add documentation on how to use the new pod template in a Jenkinsfile (need to specify the container where the build occurs).
      • Add documentation on how developers can provide an inline pod template within a Jenkinsfile. Documentation should have the following formats:
        • New YAML declarative format
        • Deprecated Groovy format
      • Existing pipelines that use the default Kubernetes Plugin Pod Templates do not break.
      • End to end testing (for client or sync plugin) verifies that the new pod templates work.

      QE Impact

      QE will need to verify that the new pod templates can successfully execute a JenkinsPipeline build.

      Docs Impact

      Documentation needs to be updated to explain how to use the new template.

      PX Impact

      Unclear if we need new CEE/PX materials beyond doc updates.

      Notes

      We currently have built-in pod templates for NodeJS and Maven, which use specialized agent images with NodeJS/Maven image.
      Blog post here outlines the process: https://developers.redhat.com/blog/2020/06/04/an-easier-way-to-create-custom-jenkins-containers/

      The Groovy style of declaring in-line pod templates is deprecated in favor of a YAML-style format.

      Existing documentation for the Jenkin pod templates: https://docs.openshift.com/container-platform/4.9/openshift_images/using_images/images-other-jenkins.html#images-other-jenkins-config-kubernetes_images-other-jenkins

            [JKNS-257] Use sidecar pattern for Jenkins pod templates

            CPaaS Service Account mentioned this issue in merge request !16 of ocp-tools / Jenkins Agent Base on branch ocp-tools-4.10-rhel-8_upstream_6d5712673efd01bfc035ed8bb1f29faf:

            Updated US source to: 8b35abf Merge pull request #1398 from akram/4.10-compute-bundle-plugins-in-build

            GitLab CEE Bot added a comment - CPaaS Service Account mentioned this issue in merge request !16 of ocp-tools / Jenkins Agent Base on branch ocp-tools-4.10-rhel-8_ upstream _6d5712673efd01bfc035ed8bb1f29faf : Updated US source to: 8b35abf Merge pull request #1398 from akram/4.10-compute-bundle-plugins-in-build

            Rolfe Dlugy-Hegwer added a comment - - edited

            gmontero@redhat.com  We release noted this deprecation as shown above in the "Release Notes Text" section. 

            We also release noted the enhancement,  JKNS-132 as follows:

            • With this update, you can run Jenkins agents as sidecar containers. You can use this capability to run any container image in a Jenkins pipeline that has a correctly configured pod template and Jenkins file. Now, to compile code, you can run two new pod templates named java-build and nodejs-builder as sidecar containers with Jenkins. These two pod templates use the latest Java and NodeJS versions provided by the java and nodejs image streams in the openshift namespace. The previous non-sidecar maven and nodejs pod templates have been deprecated. (JKNS-132)

            Rolfe Dlugy-Hegwer added a comment - - edited gmontero@redhat.com   We release noted this deprecation as shown above in the "Release Notes Text" section.  We also release noted the enhancement,  JKNS-132 as follows: With this update, you can run Jenkins agents as sidecar containers. You can use this capability to run any container image in a Jenkins pipeline that has a correctly configured pod template and Jenkins file. Now, to compile code, you can run two new pod templates named  java-build  and  nodejs-builder  as sidecar containers with Jenkins. These two pod templates use the latest Java and NodeJS versions provided by the  java  and  nodejs  image streams in the  openshift  namespace. The previous non-sidecar  maven  and  nodejs  pod templates have been deprecated. (JKNS-132)

            Adam Kaplan added a comment -

            Verified manually. Current open sub-task is automating our verification tests.

            Adam Kaplan added a comment - Verified manually. Current open sub-task is automating our verification tests.

            CPaaS Service Account mentioned this issue in merge request !1 of ocp-tools / Jenkins 2 on OpenShift on branch ocp-tools-4.9-rhel-8_upstream_5ae12931ccdefb213e9873f548ef832e:

            Updated US source to: 0c80872 Merge pull request #1364 from jitendar-singh/sidecar-smoke-test

            GitLab CEE Bot added a comment - CPaaS Service Account mentioned this issue in merge request !1 of ocp-tools / Jenkins 2 on OpenShift on branch ocp-tools-4.9-rhel-8_ upstream _5ae12931ccdefb213e9873f548ef832e : Updated US source to: 0c80872 Merge pull request #1364 from jitendar-singh/sidecar-smoke-test

            rdlugyhe - release note text using the Enhancement guidelines at https://redhat-documentation.github.io/supplementary-style-guide/#release-notes:

             

            With this update, we are both

            • providing 2 new PodTemplates for use by the Kubernetes Plug-in in Jenkins, name "java-build" and "nodejs-builder", where the latest available Java version and NodeJS version provided by the "java" and "nodejs" ImageStreams in the "openshift" namespae are utilized when using those PodTemplates to compile code in those respective languages
            • deprecating the "maven" and "nodejs" PodTemplates previously provided

            Gabe Montero added a comment - rdlugyhe - release note text using the Enhancement guidelines at https://redhat-documentation.github.io/supplementary-style-guide/#release-notes:   With this update, we are both providing 2 new PodTemplates for use by the Kubernetes Plug-in in Jenkins, name "java-build" and "nodejs-builder", where the latest available Java version and NodeJS version provided by the "java" and "nodejs" ImageStreams in the "openshift" namespae are utilized when using those PodTemplates to compile code in those respective languages deprecating the "maven" and "nodejs" PodTemplates previously provided

            OK jitensingh pkumari per adkaplan@redhat.com change to our project profiles in Jira, I've moved this Story to "Review", which is the analogous workflow state to what used to be "QE Review" with our prior settings in Jira.

             

            Hopefully this story is now on your radar for composing and executing test cases so we can complete this work.

             

            Thanks.

            Gabe Montero added a comment - OK jitensingh pkumari per adkaplan@redhat.com change to our project profiles in Jira, I've moved this Story to "Review", which is the analogous workflow state to what used to be "QE Review" with our prior settings in Jira.   Hopefully this story is now on your radar for composing and executing test cases so we can complete this work.   Thanks.

            For reference, this simplified version of the sample from the code ready container folks worked:

             

            ```

            def nodeLabel = 'spring-petclinic-pipeline-agent'

            pipeline {
              agent {
                kubernetes {
                  cloud 'openshift'
                  label nodeLabel
                  yaml """
            apiVersion: v1
            kind: Pod
            metadata:
              labels:    "k8s.io/apimachinery/pkg/labels"

                worker: ${nodeLabel}
            spec:
              containers:
              - name: jnlp
                image: registry.redhat.io/openshift4/ose-jenkins-agent-base:v4.2.15
                args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
              - name: java
                image: registry.redhat.io/codeready-workspaces/stacks-java-rhel8:2.0
                command:
                - cat
                tty: true
              imagePullSecrets:
                - name: jenkins-pull-secret
            """
                }
              }
              
              options

            {     timeout(time: 20, unit: 'MINUTES')   }

              stages {
                stage('Build App') {
                  steps {
                    container("java")

            {                        sh "mvn --version"                    }

                  }
                }
               
              }

             
            }

            ```

            Gabe Montero added a comment - For reference, this simplified version of the sample from the code ready container folks worked:   ``` def nodeLabel = 'spring-petclinic-pipeline-agent' pipeline {   agent {     kubernetes {       cloud 'openshift'       label nodeLabel       yaml """ apiVersion: v1 kind: Pod metadata:   labels:    "k8s.io/apimachinery/pkg/labels"     worker: ${nodeLabel} spec:   containers:   - name: jnlp     image: registry.redhat.io/openshift4/ose-jenkins-agent-base:v4.2.15     args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']   - name: java     image: registry.redhat.io/codeready-workspaces/stacks-java-rhel8:2.0     command:     - cat     tty: true   imagePullSecrets:     - name: jenkins-pull-secret """     }   }      options {     timeout(time: 20, unit: 'MINUTES')   }   stages {     stage('Build App') {       steps {         container("java") {                        sh "mvn --version"                    }       }     }       }   } ```

            So the hang I reported in my last comment disappeared after launching new clusters (4.6, 4.9, 4.10) the following day.  Have no idea what happened, but am currently unblocked.  We'll see how today's clusters make out

            Gabe Montero added a comment - So the hang I reported in my last comment disappeared after launching new clusters (4.6, 4.9, 4.10) the following day.  Have no idea what happened, but am currently unblocked.  We'll see how today's clusters make out

             
            So something between 1.29.0 and 1.30.1 of the k8s plugin changed how things work, and broke the form of sidecar noted by the code ready container folks.  I'll start trying to see if I can gleam what changed exactly and if this is expected or a side effect, and if there is a config tweak which allows ^^ to work again.
             
             

            Gabe Montero added a comment -   So something between 1.29.0 and 1.30.1 of the k8s plugin changed how things work, and broke the form of sidecar noted by the code ready container folks.  I'll start trying to see if I can gleam what changed exactly and if this is expected or a side effect, and if there is a config tweak which allows ^^ to work again.    

            a post planning question adkaplan@redhat.com abenaiss - if you all look at the various flavors of multiple container support for the k8s plugin at https://github.com/jenkinsci/kubernetes-plugin#multiple-containers-support, which one(s) of those were you considering "Deprecated Groovy format" ?

             

            I think you all mean

             

            ```

            podTemplate(containers: [ containerTemplate(name: 'maven', image: 'maven:3.8.1-jdk-8', command: 'sleep', args: '99d'), containerTemplate(name: 'golang', image: 'golang:1.16.5', command: 'sleep', args: '99d') ])

            ```

             

            but wanted to make sure.

             

            thanks

            Gabe Montero added a comment - a post planning question adkaplan@redhat.com abenaiss - if you all look at the various flavors of multiple container support for the k8s plugin at https://github.com/jenkinsci/kubernetes-plugin#multiple-containers-support, which one(s) of those were you considering "Deprecated Groovy format" ?   I think you all mean   ``` podTemplate(containers: [ containerTemplate(name: 'maven', image: 'maven:3.8.1-jdk-8', command: 'sleep', args: '99d'), containerTemplate(name: 'golang', image: 'golang:1.16.5', command: 'sleep', args: '99d') ]) ```   but wanted to make sure.   thanks

              gmontero@redhat.com Gabe Montero
              adkaplan@redhat.com Adam Kaplan
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: