Jenkins slave pod keeps always running

1/21/2020

I am newbie for using Jenkins on Kubernetes. I have installed using helm stable chart for Jenkins. I can create and execute Job.

Below are the pain areas:

  1. Pods are taking time till slave pod comes up and running (It is becuase of 6 containers running in pod).
  2. Trying to keep always slave(pod) running. Please correct me if my approach is wrong to keep slave(pod) always running. Unfortunately using Kubernetes agent(inside pipeline), I still struggling where to add "podRetention" as always.

Also few terms in Jenkins are no explanable in official documentation-

i. idleMinutes

ii. instanceCap

iii. activeDeadlineSeconds

iv. slaveConnectTimeout

-- Ashish Kumar
eks
jenkins
jenkins-pipeline
kubernetes

1 Answer

1/21/2020

For a declarative pipeline you would use idleMinutes to keep the pod longer

pipeline {
    agent {
       kubernetes {
            label "myPod"
            defaultContainer 'docker'
            yaml readTrusted('kubeSpec.yaml')
            idleMinutes 30
        }
    }

the idea is to keep the pod alive for a certain time for jobs that are triggered often, the one watching master branch for instance. That way if developers are on rampage pushing on master, the build will be fast. When devs are done we don't need the pod to be up forever and we don't want to pay extra resources for nothing so we let the pod kill itself

-- fredericrous
Source: StackOverflow