Kubernetes plugin for Jenkins: jnlp tasks are not released

12/12/2019

Before I start, I can't put images correctly

He created a custom Dockerfile for a Jenkins-Master:

FROM jenkins/jenkins

# Sets the number of jenkins executors to 0
COPY executors.groovy /usr/share/jenkins/ref/init.groovy.d/executors.groovy

# Install kubernetes plugin - scaling
RUN /usr/local/bin/install-plugins.sh kubernetes
RUN /usr/local/bin/install-plugins.sh nodejs

# Install Maven and net-tools
USER root

RUN apt-get update && apt-get install -y maven net-tools

USER jenkins

I use this image to run a Jenkins master in Kubernetes on a Minikube platform. The configuration of the Kubernetes Plugin cloud is as follows:

enter image description here

IMAGEN- Config plugin Kubernetes I

enter image description here

IMAGEN- Config plugin Kubernetes II

As you can see, I use an image of the custom slave. The problem comes when I try to run my own custom pod template. That is, when the template name of the container is "jnlp" the slaves are not released and therefore there is no communication between the master and the slaves. On the contrary, if I change this name to a different one, for example "jenkins-slave" the slaves are launched correctly and Jenkins' work is executed on the slave.

enter image description here

IMAGEN- Name Container Template

The next problem comes when the name of the container template is different from "jnlp", because two containers are created in the slave pod ("jnlp" and "jenkins-slave"). This would not be a problem if executing any command of a Jenkins task was executed directly on the Jnlp container, which does not contain my custom slave image.

Therefore, the question is: How could I execute a task (not pipeline) with a template of a custom container? For example, to execute a task as simple as the following:

enter image description here

IMAGEN- Ejemplo Tarea Jenkins I

enter image description here

IMAGEN- Ejemplo Tarea Jenkins II

enter image description here

IMAGEN- Ejemplo Tarea Jenkins III

1) Why if I call the container name "Jnlp" (to overwrite the default image of the Jenkins slave), the task is not launched successfully and the slave does not communicate with the Kubernetes master?

2) When I change the name of the container at least the task is executed, but two containers are created in the pods ("jnlp" and "jenkins-slave" for example). Why if I execute a command as simple as "node -v" it is executed in the "jnlp" container of the pod, instead of in the "jenkins-slave" container ?? This is a custom slave container, which is built according to my preferences.

This is a montage that I have made, of how I would like the information of the Kubernetes pods in execution and their content to remain:

enter image description here

IMAGEN- Resultado Esperado de Kubernetes

I hope someone can help me, since I have visited many forums and nobody has a valid configuration for this case.

-- mduque
containers
jenkins
jnlp
kubernetes

0 Answers