• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • kubernetes-plugin
    • None
    • Jenkins: 2.263.3
      Kubernetes plugin: 1.28.7
      Kubernetes API plugin: 4.11.1

      When setting up a pod with a custom image, it appears the image key within the yaml sent to Kubernetes contains two image keys. One is the custom image that I defined <private docker registry>/jenkins-inbound:bionic-jdk11 and the other is jenkins/inbound-agent:4.3-4.

      This creates an issue where all operations are ran on the later image (jenkins/inbound-agent:4.3-4), and not my custom image.

       

      ---
       apiVersion: "v1"
       kind: "Pod"
       metadata:
         labels:
           jenkins: "agent"
           app.kubernetes.io/managed-by: "jenkins"
           jenkins/label: "k8s-jdk8-wip"
           jenkins/label-digest: "2ad391d593c63b19416b9dd75b9ab723b8aa17c7"
         name: "pod-jdk8-4vmjc"
       spec:
         containers:
         - args:
           - "9999999"
           command:
           - "sleep"
           image: "<private docker registry>/jenkins-inbound:bionic-jdk11"
           imagePullPolicy: "Always"
           name: "jdk11"
           resources:
             limits: {}
             requests: {}
           tty: false
           volumeMounts:
           - mountPath: "/srv/cache"
             name: "volume-0"
             readOnly: false
           - mountPath: "/home/jenkins/agent"
             name: "workspace-volume"
             readOnly: false
           workingDir: "/home/jenkins/agent"
         - env:
           - name: "JENKINS_PROTOCOLS"
             value: "JNLP4-connect"
           - name: "JENKINS_SECRET"
             value: "********"
           - name: "JENKINS_AGENT_NAME"
             value: "pod-jdk8-4vmjc"
           - name: "JENKINS_DIRECT_CONNECTION"
             value: "jenkins.********:42232"
           - name: "JENKINS_INSTANCE_IDENTITY"
             value: "********""
           - name: "JENKINS_NAME"
             value: "pod-jdk8-4vmjc"
           - name: "JENKINS_AGENT_WORKDIR"
             value: "/home/jenkins/agent"
           image: "jenkins/inbound-agent:4.3-4"
           name: "jnlp"
           resources:
             limits: {}
             requests:
               memory: "256Mi"
               cpu: "100m"
           volumeMounts:
           - mountPath: "/srv/cache"
             name: "volume-0"
             readOnly: false
           - mountPath: "/home/jenkins/agent"
             name: "workspace-volume"
             readOnly: false
         hostNetwork: false
         nodeSelector:
           kubernetes.io/os: "linux"
         restartPolicy: "Never"
         volumes:
         - name: "volume-0"
           persistentVolumeClaim:
             claimName: "netapp"
             readOnly: false
         - emptyDir:
             medium: ""
           name: "workspace-volume"
      

          [JENKINS-64849] custom image ignored by kubernetes plugin.

          If you want to override the definition of the default container, I believe you must define a container with same name: "jnlp".

          Jonathan Rogers added a comment - If you want to override the definition of the default container, I believe you must define a container with same name: "jnlp".

          Mike Delaney added a comment -

          jrogers, yeah that was it. I changed the image name to jnlp as you suggested and that seems to have tricked the plugin into using my custom jnlp image.

           Thanks for the info.

          Mike Delaney added a comment - jrogers , yeah that was it. I changed the image name to jnlp as you suggested and that seems to have tricked the plugin into using my custom jnlp image.  Thanks for the info.

          mdelaney You're welcome. BTW, I learned how to customize the JNLP container from the documentation: https://plugins.jenkins.io/kubernetes/

          Jonathan Rogers added a comment - mdelaney You're welcome. BTW, I learned how to customize the JNLP container from the documentation: https://plugins.jenkins.io/kubernetes/

          Roman added a comment -

          Hi there. I've faced with the similar issue on Jenkins 2.289.3 and kubernetes plugin 1.31.1. 

          I've tried to set "Container template" as a jnlp and retagged my custom image as a jnlp but it didn't bring a result. 

          In the job's output, I see a changed name and default image name. 

          image: "jenkins/inbound-agent:4.3-4"
          

          Maybe you can share any other tricks or thoughts?

          Roman added a comment - Hi there. I've faced with the similar issue on Jenkins 2.289.3 and kubernetes plugin 1.31.1.  I've tried to set "Container template" as a jnlp and retagged my custom image as a jnlp but it didn't bring a result.  In the job's output, I see a changed name and default image name.  image: "jenkins/inbound-agent:4.3-4" Maybe you can share any other tricks or thoughts?

          @Roman Can you share your pod yaml?

          Jonathan Rogers added a comment - @Roman Can you share your pod yaml?

            Unassigned Unassigned
            mdelaney Mike Delaney
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: