Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49313

Incorrect podTemplate deployed starting in 1.1.4

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • kubernetes-plugin
    • None
    • Jenkins 2.104
      kubernetes-plugin 1.1.4

      After upgrading to 1.1.4, my agents were getting deployed as what appeared to be a default template instead of my custom pod template.  My custom template includes a custom container, but the Pod being created only had the jnlp container in it.

      Here is my plugin configuration that works correctly in 1.1.3:

       

      <org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud plugin="kubernetes@1.1.3">
       <name>kubernetes</name>
       <defaultsProviderTemplate></defaultsProviderTemplate>
       <templates>
       <org.csanchez.jenkins.plugins.kubernetes.PodTemplate>
       <inheritFrom></inheritFrom>
       <name>rok8sslave</name>
       <namespace>jenkins</namespace>
       <privileged>false</privileged>
       <alwaysPullImage>false</alwaysPullImage>
       <instanceCap>2</instanceCap>
       <slaveConnectTimeout>100</slaveConnectTimeout>
       <idleMinutes>1</idleMinutes>
       <activeDeadlineSeconds>1800</activeDeadlineSeconds>
       <label>rok8s</label>
       <nodeSelector></nodeSelector>
       <nodeUsageMode>EXCLUSIVE</nodeUsageMode>
       <customWorkspaceVolumeEnabled>false</customWorkspaceVolumeEnabled>
       <workspaceVolume class="org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.EmptyDirWorkspaceVolume">
       <memory>false</memory>
       </workspaceVolume>
       <volumes>
       <org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume>
       <mountPath>/usr/bin/docker</mountPath>
       <hostPath>/usr/bin/docker</hostPath>
       </org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume>
       <org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume>
       <mountPath>/var/run/docker.sock</mountPath>
       <hostPath>/var/run/docker.sock</hostPath>
       </org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume>
       </volumes>
       <containers>
       <org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate>
       <name>rok8s</name>
       <image>repository.internal/org/ciimage</image>
       <privileged>false</privileged>
       <alwaysPullImage>true</alwaysPullImage>
       <workingDir>/home/jenkins</workingDir>
       <command>/bin/sh -c</command>
       <args>cat</args>
       <ttyEnabled>true</ttyEnabled>
       <resourceRequestCpu></resourceRequestCpu>
       <resourceRequestMemory></resourceRequestMemory>
       <resourceLimitCpu></resourceLimitCpu>
       <resourceLimitMemory></resourceLimitMemory>
       <envVars/>
       <ports/>
       <livenessProbe>
       <execArgs></execArgs>
       <timeoutSeconds>0</timeoutSeconds>
       <initialDelaySeconds>0</initialDelaySeconds>
       <failureThreshold>0</failureThreshold>
       <periodSeconds>0</periodSeconds>
       <successThreshold>0</successThreshold>
       </livenessProbe>
       </org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate>
       </containers>
       <envVars/>
       <annotations/>
       <imagePullSecrets/>
       </org.csanchez.jenkins.plugins.kubernetes.PodTemplate>
       </templates>
       <serverUrl>https://kubernetes.default</serverUrl>
       <skipTlsVerify>false</skipTlsVerify>
       <namespace>jenkins</namespace>
       <jenkinsUrl>http://jenkins-ui.jenkins.svc.cluster.local:8080</jenkinsUrl>
       <jenkinsTunnel>jenkins-discovery.jenkins.svc.cluster.local:50000</jenkinsTunnel>
       <containerCap>10</containerCap>
       <retentionTimeout>5</retentionTimeout>
       <connectTimeout>0</connectTimeout>
       <readTimeout>0</readTimeout>
       <labels class="com.google.common.collect.ImmutableMap">
       <entry>
       <string>jenkins</string>
       <string>slave</string>
       </entry>
       </labels>
       <maxRequestsPerHost>32</maxRequestsPerHost>
       </org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud>
       
      

       

      And here is the basic format of the pipeline:

      podTemplate(label: 'rok8s') {
        node('rok8s') {
          stage('Name') {
            container('rok8s') {
              //do stuff
            }
          }
        }
      } 

          [JENKINS-49313] Incorrect podTemplate deployed starting in 1.1.4

          podTemplate in pipeline is defining a new PodTemplate, just remove that line. Otherwise you have 2 PodTemplates for the same label

          Carlos Sanchez added a comment - podTemplate in pipeline is defining a new PodTemplate, just remove that line. Otherwise you have 2 PodTemplates for the same label

          Corey O'Brien added a comment - - edited

          Was that an intentional change? In 1.1.3 `podTemplate(label: 'asdf')` would make a template based on a global template with the label `asdf`. In 1.1.4, it does something different, creating a template based on the the default template and adding the label `asdf`.

          The end result is that in 1.1.3, podTemplate(label: 'rok8s') would create a Pod named "rok8sslave-" with 2 containers just like in the global settings. In 1.1.4, it creates a Pod named "jenkins-slave-" with 1 container like the default.

          Corey O'Brien added a comment - - edited Was that an intentional change? In 1.1.3 `podTemplate(label: 'asdf')` would make a template based on a global template with the label `asdf`. In 1.1.4, it does something different, creating a template based on the the default template and adding the label `asdf`. The end result is that in 1.1.3, podTemplate(label: 'rok8s') would create a Pod named "rok8sslave-" with 2 containers just like in the global settings. In 1.1.4, it creates a Pod named "jenkins-slave-" with 1 container like the default.

          that's not how it works, podTemplate has always created a new pod template with only the default jnlp container

          I guess in 1.1.3 the global template was picked, in 1.1.4 the template in the jenkinsfile is picked, which matches what a user would expect

          Carlos Sanchez added a comment - that's not how it works, podTemplate has always created a new pod template with only the default jnlp container I guess in 1.1.3 the global template was picked, in 1.1.4 the template in the jenkinsfile is picked, which matches what a user would expect

            csanchez Carlos Sanchez
            coreypobrien Corey O'Brien
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: