1

I configured Jenkins on a K8s cluster and setup Jenkins build pipeline. Once build execute It creates the jenkins-slave pod and after the build, the pod will terminate.

The use case is basically if all my workers in Jenkins goes full, I want to auto-scale (increase the number of slaves) if it comes back down, I would like to reduce the slaves count.

Is it possible? and How I can do it from k8s.

Rico
  • 58,485
  • 12
  • 111
  • 141
bibincatchme
  • 333
  • 4
  • 10
  • Not sure I'm following but the slaves == workers in this case and Jenkins K8s plugin will attempt to schedule a new worker for each job attempting to run, and terminate those worker pods when the job completes. Can you expand on your question? – Chad Jul 23 '20 at 01:50
  • @Chad Yes slaves == workers, Assum that my nodes are full of slaves (n no. of build executing), is it possible to scale the slaves of each build?. I think for each build there will be one slave create because slaves are POD kind. – bibincatchme Jul 23 '20 at 04:13
  • Correct, you cannot scale pods for a build. You define all of your containers in a pod and additionally you can define the CPU and Memory request (or initial values) for each container inside of that pod. Would that resolve what you are trying to do? Or why do you think you need multiple pods? – Chad Jul 24 '20 at 11:24
  • @Chad Could you help me to explain how the Jenkins-slave pod working.?. podTemplate(label: 'mypod', containers: [ containerTemplate(name: 'git', image: 'alpine/git', ttyEnabled: true, command: 'cat'), containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true) For this pipeline. It will create a pod with Jenkins-slave image after that how it works ? – bibincatchme Aug 04 '20 at 12:45
  • @Chad When the job is triggered from master it will look for the slave configuration details. Based on the configuration given in the master using the JNLP Jenkins slave image, a slave pod is created. The pipeline executed on this slave container will start the containers which we describe in our conatinerTemplate in the pipeline. Is it the correct method of working? – bibincatchme Aug 04 '20 at 15:54
  • When a job is triggered from the master, in your example, you will have three containers in that pod template: alpine/git, docker, jnlp (which is always added by jenkins). The job should define steps which will specify which container should be used for that particular step. You need to be explicit about where you want something to run. – Chad Aug 05 '20 at 13:32

0 Answers0