Base image for all k8s images.
Use in Dockerfile:
FROM cloutainer/k8s-jenkins-slave-base:v21
COPY docker-entrypoint-hook.sh /opt/docker-entrypoint-hook.sh
# ...
USER jenkins
Always provide a file called docker-entrypoint-hook.sh
and copy it to /opt/
.
It will be sourced by the entrypoint before the JNLP remoting jar establishes the connection to Jenkins.
A Jenkins Slave Dockerized Container is started by Kubernetes with the following parameters:
- Docker CMD parameters (args):
secret
andnodeName
- We will use
JENKINS_NAME
Env var instead ofnodeName
- We will use
JENKINS_SECRET
Env var instead ofsecret
- We will use
- Docker ENV Vars:
JENKINS_LOCATION_URL: https://jenkins.foo.com/
JENKINS_SECRET: 050...42d
JENKINS_JNLP_URL: http://jenkins.foo.com:8080/computer/k8s-jenkins-slave-
nodejs-xvfb-chrome-21ce6ca6fe87e/slave-agent.jnlp
JENKINS_NAME: k8s-jenkins-slave-nodejs-xvfb-chrome-21ce6ca6fe87e
JENKINS_URL: http://jenkins.foo.com:8080
HOME: /work
The secret
and nodeName
is the passed to the JNLP remoting JAR slave.jar
to connect to the Jenkins Host via JNLP protocol.
The outline of the process is as follows:
- container creation with
secret
andnodeName
- inside docker-entrypoint:
- Download of
${JENKINS_URL}/jnlpJars/slave.jar
. - Executing
java -jar slave.jar -url ${JENKINS_URL} ${secret} ${nodeName}
.
- Download of