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

How to reuse a pod across job executions?

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • kubernetes-plugin
    • None
    • Jenkins version: 2.249.1
      kubernetes-plugin version: 1.27.0

      I'm trying to reuse the same POD on all build executions but I can't even by setting the option idleMinutes to 1h for example. For each execution, the POD's name and it's labels are always different. Perhaps this is the main cause. I think that I must do something else together with idleMinutes to make it reusable by kubernetes-plugin, but I don't which option should I need to use to achieve that. The documentation isn't clear enough about it.

      Here is a snippet: of what I'm doing:

      I have a file called cicd-pod.yaml which serves as pod template. Here is it's contents:

       

      apiVersion: v1
      kind: Pod
      metadata:
      labels:
        eks.amazonaws.com/fargate-profile: jenkins
        nodegroup: fargate
      spec:
      containers:
        - name: kubernetes
          imagePullPolicy: IfNotPresent
          image: ubuntu:latest
          resources:
            requests:
              cpu: "3"
            limits:
              cpu: "4"
           command: ['cat']
           tty: true
      

      Here is the declarative pipeline snipet:

       

      pipeline {
        agent {
          kubernetes {
            slaveConnectTimeout "600"
            idleMinutes "60"
            yamlFile "cicd-pod.yaml"
          }
        }
      
        stages {
          stage('Prepare POD') {
            steps {
              container('kubernetes') {
                sh 'echo test'
              }
            }
          }
        }
      }
      

       
       

            Unassigned Unassigned
            galindro Bruno Galindro da Costa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: