Change the default JNLP image for kubernetes agents provisioning

Issue

You would like to modify the default JNLP image in the kubernetes plugin jenkins/jnlp-slave:alpine

Environment

Resolution

By default, the kubernetes plugin uses the jenkins/jnlp-slave:alpine JNLP docker image from DockerHub. However, enterprises might need to:

  • Use a Private Docker Registry
  • Customize the default JNLP image

In CloudBees Core - Modern cloud platforms, there are two different approaches for defining the Kubernetes Pod Templates. You can define them in the Managed Master itself or through a Kubernetes Shared Cloud. The last option makes the Kubernetes Pod Templates to be shared amongst all the Managed Masters.

Kubernetes plugin

In case your Pod Templates are defined at Managed Master level, then you just need to add the Java Argument -Dorg.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.defaultImage=<REGISTRY>/<IMAGE> to the Managed Master. This can be done in the Java Options section under the Managed Master configuration. A re-provision is needed.

modern-cloud-default-jnlp-image.png

kubernetes shared cloud

In this last case, there are two different approaches.

In the first one, in the Kubernetes Shared Cloud configuration there is an option called Defaults Provider Template Name, which provides a way of using this template as a parent to all other pod templates. If you define here your JNLP container template - like in the image below, it will be used for all the Managed Masters which uses Kubernetes Pod Templates based on this parent template.

modern-cloud-default-jnlp-image-default-provider.png

In the second approch, we just need to ensure that the template specified in Defaults Provider Template Name in the Kubernetes Shared Cloud configuration is not defining any JNLP container and then add the Java argument -Dorg.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStepExecution.defaultImage=<REGISTRY>/<IMAGE> to the Managed Master. This can be done in the Java Options section under the Managed Master configuration. A re-provision is needed.

modern-cloud-default-jnlp-image.png

Tested products/plugins version

The latest update of this article was tested with:

Have more questions?

0 Comments

Please sign in to leave a comment.