Does Jenkins agent node need a public IP?

238 Views Asked by At

I am trying to set up a Jenkins agent node in AWS. Due to cost reasons, it is planned to switch off the instance whenever it is not needed. In AWS, the public IP will have a small cost if it is assigned for an instance that is shutdown, and we are trying to avoid it. Do we really need to have a public IP to connect the Jenkins controller to the Jenkins agent node? Appreciate your suggestions.

2

There are 2 best solutions below

0
Atxulo On

You will always need some kind of public IP.

I guess you are using an elastic ip and your Jenkins 'built-in' node isn't in AWS, and this node is trying to connect with your 'agent' node in AWS.

I'm not really sure but, if your 'built-in' node is accesible from Internet, you could try this:

  1. When you configure a new agent there is an option "Launch agent by connecting it to the controller".

  2. If you configure a node with that option, you should see a command like this in the jenkins user interface:

java -jar agent.jar -jnlpUrl https://JENKINS_URL/computer/AGENT_NAME/jenkins-agent.jnlp -secret 8d7...695 -workDir "local/path"
  1. You shoud run that command in your AWS instance and it will connect to your Jenkins 'built-in' agent, and, AFAIK, you won´t need an elastic ip, but a public ip (dynamic, but it doesn´t matter).
0
thekbb On

No.

But really - the answer is, "It depends". Are the jenkins-agent and jenkins controller in the same VPC (or otherwise routable)? if that answer is 'yes', then you may not need the jenkins agent to have a public IP.