#.toolbox in initContainer too slow in my env, cost about 2 min.
#.exec continers cached for some hours, keep a queue. diff type build with diff queue. new pod init cost time.
#.src clone cached in exec containers. avoid each build with a new full clone thats cost much time.
@huapox Can you provide more details and context because I’m having hard times trying to decipher your post. Are these suggestions? If so please open a new post for every different suggestion so I can provide a detailed answer.
Sorry for the poor description.
Toolbox in initContainer too slow in my env, cost about 2 min.
This item had resolved. just because the master/worker-node of my cluster are communicate with limited bandwidth. Most time cost in network transmisson.
Task-pod cached with a worker queue
1.Task-pod cached for some hours to keep alive even a job is done.(the alive time can be set, just like jenkins-kubernetes plugin)
2.Keep a queue to record the status of each task-pod. diff type build with diff queue.
3.Each build starts with a judge: first use the non-busy cached task-pod of the worker queue. if none then create a new one.
I’m doing this with a groovy define in jenkins. In order to save the time of new pod initial.
Just like each worker are always online. And the number of the worker can keep a balence to the job’s build frequency.
Src clone cached in exec containers(volume mounts).
Avoid each build with a new full clone that cost much time.
@sgotti The groovy scripts reffered in my Jenkinsfile
:
@NonCPS
def getEmpSlave(preffix) {//computers
for (c in jenkins.model.Jenkins.instance.computers) {
if (c.node.labelString.contains(preffix) && c.countBusy() == 0) {
return c.node.labelString
}
}
return ""
}
def deploy(id) {
def vlabel = "k8s-${UUID.randomUUID().toString().substring(0,8)}"
ret = this.getEmpSlave("k8s-")
if ( ret.length() != 0) {
vlabel = ret
}
podTemplate(label: vlabel, cloud: 'kubernetes',