Jenkins: external nodes fail to register to master on Kubernetes

6/19/2019

I am looking for the way to pass JNLP though Kubernetes nginx ingress. Any advise would be strongly appreciated. Specifically I am using "Rancher 2" cluster with built in Nginx ingress.

In details my issue is: I am executing Jenkins master as a workflow on top of Kubernetes cluster and I would like to add external machine as a slave node to this Jenkins instance.

Jenkins JNLP is exposed by L7 nginx ingress with dedicated hostname, and this hostname is configure in Advanced/Tunnel connection through of the slave node. I can query this address by http from the slave with curl and it returns valid response:

Jenkins-Agent-Protocols: JNLP-connect, JNLP2-connect, JNLP3-connect, JNLP4-connect, Ping Jenkins-Version: 2.176.1 Jenkins-Session: 0fe8c345 Client: 10.42.0.0 Server: 10.42.1.37 Remoting-Minimum-Version: 3.4

However with JNLP it doesn't work. When I try to register new node with this command:

java -jar agent.jar -jnlpUrl http://devops.xxxx.local/jenkins/computer/EPHEMERAL-WIN-NODE/slave-agent.jnlp -secret xxxxxxxxxxxxxxx

It returns followin error: ConnectionRefusalException: Server didn't accept the handshake: HTTP/1.1 400 Bad Request

To make sure that it is not a connectivity issue, I changed tunneling address of the node to direct address of worker node and it is working well in this case. However, it can't be the solution, because Kubernetes can change this address dynamically.

-- Moisei
jenkins
jnlp
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

7/10/2019

The JNLP port uses a tcp protocol, not http. You can't http proxy it through nginx. You could try with nginx tcp proxying https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/

-- csanchez
Source: StackOverflow