Change the Jenkins URL that Kubernetes cloud agents connect to

Issue

  • I want to change the URL that kubernetes agents are using to connect to Jenkins

Environment

Resolution

The Kubernetes Plugin passes the Jenkins URL to the jnlp container in agent pods as an environment variable and the agent process connects to Jenkins using the script: https://github.com/jenkinsci/docker-jnlp-slave/blob/master/jenkins-slave.

By default, the Jenkins URL configured under manage Manage Jenkins > Configure System is used. In most cases, this is acceptable. But in some cases it is required that agents connect to a different endpoint, for example to connect through a specific proxy load balancer or via internal IP / hostnames.

The Kubernetes Plugin resolves the Jenkins URL from different sources in that order:

  1. The “Jenkins URL” configured for the Kubernetes Cloud under Manage Jenkins > Configure System > Cloud
  2. If empty or not specified, the value of the System Property KUBERNETES_JENKINS_URL (i.e. passing -DKUBERNETES_JENKINS_URL to the Jenkins’s startup)
  3. If empty or not specified, the value of the Environment Variable KUBERNETES_JENKINS_URL
  4. If empty or not specified, the “Jenkins URL” configured under Manage Jenkins > Configure System
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.