Change the default JNLP image for kubernetes agents provisioning

Issue

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

Environment

Resolution

By default, the kubernetes plugin uses the jenkins/inbound-agent: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?

1 Comments

  • 0
    Avatar
    Dumitru Gutu

    This is very helpful in general but not helpful at all when you are using regular opensource Jenkins :(

    When you run on enterprise, you are not allowed to pull anything from outside, so how do I configure multiple registries based on the namespace in which the jenkins agent will run?

    Edited by Dumitru Gutu
Please sign in to leave a comment.