0

I am trying to use K8s to set up a Jenkins slave, passing correct agent name and secret but tries to connect to a weird url:

Keeps creating slaves and removing them with the exact same logs.

Master logs:

2020-02-03 21:20:39.980+0000 [id=26]    INFO    o.c.j.p.k.KubernetesCloud#provision: Template for label slave: jenkins-slave
2020-02-03 21:20:50.005+0000 [id=31]    INFO    hudson.slaves.NodeProvisioner#lambda$update$6: Kubernetes Pod Template provisioning successfully completed. We have now 3 computer(s)
2020-02-03 21:20:50.026+0000 [id=26914] INFO    o.c.j.p.k.KubernetesLauncher#launch: Created Pod: toks1/jenkins-slave-ncn4x
2020-02-03 21:20:54.547+0000 [id=26922] INFO    h.TcpSlaveAgentListener$ConnectionHandler#run: Connection #122 failed: java.io.EOFException
2020-02-03 21:20:54.660+0000 [id=26923] INFO    h.TcpSlaveAgentListener$ConnectionHandler#run: Accepted JNLP4-connect connection #123 from /10.128.0.1:41682
2020-02-03 21:20:54.864+0000 [id=26914] INFO    o.c.j.p.k.KubernetesLauncher#launch: Pod is running: toks1/jenkins-slave-ncn4x
2020-02-03 21:20:54.867+0000 [id=26914] INFO    o.c.j.p.k.KubernetesLauncher#launch: Waiting for agent to connect (0/100): jenkins-slave-ncn4x
2020-02-03 21:20:55.885+0000 [id=26914] INFO    o.c.j.p.k.KubernetesLauncher#launch: Waiting for agent to connect (1/100): jenkins-slave-ncn4x
2020-02-03 21:20:56.891+0000 [id=26914] INFO    o.c.j.p.k.KubernetesLauncher#launch: Container is terminated jenkins-slave-ncn4x [jnlp]: ContainerStateTerminated(containerID=docker://16631d7785e73264c48e814ae56c337293d7028102e5ce7845bdb8fd96664238, exitCode=255, finishedAt=2020-02-03T21:20:55Z, message=null, reason=Error, signal=null, startedAt=2020-02-03T21:20:53Z, additionalProperties={})
2020-02-03 21:20:56.927+0000 [id=26914] SEVERE  o.c.j.p.k.KubernetesLauncher#logLastLines: Error in provisioning; agent=KubernetesSlave name: jenkins-slave-ncn4x, template=PodTemplate{inheritFrom='', name='jenkins-slave', namespace='toks1', hostNetwork=false, label='slave', nodeSelector='', nodeUsageMode=EXCLUSIVE, workspaceVolume=EmptyDirWorkspaceVolume [memory=false], containers=[ContainerTemplate{name='slave', image='docker.io/fabstao/jenkins-okd-slave:3', alwaysPullImage=true, workingDir='/home/jenkins/agent', command='', args='', resourceRequestCpu='', resourceRequestMemory='', resourceLimitCpu='', resourceLimitMemory='', envVars=[KeyValueEnvVar [getValue()=http://jenkins-gtsmex:8080 , getKey()=JENKINS_URL], KeyValueEnvVar [getValue()=slave-gts, getKey()=JENKINS_AGENT_NAME], KeyValueEnvVar [getValue()=2a1be5874407a37957eeba186c228c756ac8dbc78f0c4edb735399d15834d5ca, getKey()=JENKINS_SECRET]], livenessProbe=org.csanchez.jenkins.plugins.kubernetes.ContainerLivenessProbe@70ba28dc}]}. Container jnlp exited with error 255. Logs: INFO: Using Remoting version: 3.35
Feb 03, 2020 9:20:54 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /home/jenkins/agent/remoting as a remoting work directory
Feb 03, 2020 9:20:54 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to /home/jenkins/agent/remoting
Feb 03, 2020 9:20:54 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://jenkins-gtsmex-toks1.toks1.default.svc.cluster.local/ ]
Feb 03, 2020 9:20:54 PM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: Failed to connect to http://jenkins-gtsmex-toks1.toks1.default.svc.cluster.local/tcpSlaveAgentListener/:  jenkins-gtsmex-toks1.toks1.default.svc.cluster.local
java.io.IOException: Failed to connect to http://jenkins-gtsmex-toks1.toks1.default.svc.cluster.local/tcpSlaveAgentListener/:  jenkins-gtsmex-toks1.toks1.default.svc.cluster.local
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:206)
    at hudson.remoting.Engine.innerRun(Engine.java:527)
    at hudson.remoting.Engine.run(Engine.java:488)
Caused by: java.net.UnknownHostException: jenkins-gtsmex-toks1.toks1.default.svc.cluster.local
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
    at sun.net.www.http.HttpClient.New(HttpClient.java:339)
    at sun.net.www.http.HttpClient.New(HttpClient.java:357)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:203)
    ... 2 more

Slave logs:

Feb 03, 2020 9:27:13 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: slave-gts
Feb 03, 2020 9:27:13 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Feb 03, 2020 9:27:13 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 3.40
Feb 03, 2020 9:27:13 PM hudson.remoting.Engine startEngine
WARNING: No Working Directory. Using the legacy JAR Cache location: /home/jenkins/.jenkins/cache/jars
Feb 03, 2020 9:27:14 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://jenkins-gtsmex:8080 ]
Feb 03, 2020 9:27:14 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
Feb 03, 2020 9:27:14 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Agent discovery successful
  Agent address: jenkins-gtsmex
  Agent port:    50000
  Identity:      f5:f7:64:eb:8c:aa:57:81:07:27:2e:38:e1:93:b7:e5
Feb 03, 2020 9:27:14 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
Feb 03, 2020 9:27:14 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to jenkins-gtsmex:50000
Feb 03, 2020 9:27:14 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Trying protocol: JNLP4-connect
Feb 03, 2020 9:27:14 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Remote identity confirmed: f5:f7:64:eb:8c:aa:57:81:07:27:2e:38:e1:93:b7:e5
Feb 03, 2020 9:27:14 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connected

Kubernetes: Openshift OKD 3.11 Jenkins: 2.218

Please help

fabstao
  • 9
  • 1
  • 6

3 Answers3

0

First access http://your-jenkins-ip:8080/configureSecurity/ and set value Agents:TCP port for JNLP agents to random.

Then set working directory to /home/jenkins.

Take a look here: jenkins-kubernetes.

Official documentation: jenkins-plugin-kubernetes.

Malgorzata
  • 6,409
  • 1
  • 10
  • 27
  • 1
    Thanks but didn't work, same issue, Jenkins is appending a : to the end of tcpSlaveAgentListener, if I try the URL without the ":" then the link works, It works on podman but is not working on Kubernetes, cheers – fabstao Feb 04 '20 at 18:47
  • Do you have jenkins service exposed in proper default namespace ? – Malgorzata Feb 05 '20 at 08:25
  • Hi, I will close this issue because I updated the Jenkins image and now I have different issues with OKD 3.11 that I don't on Openshift 4.3, thanks! – fabstao Feb 05 '20 at 20:48
0

I updated Jenkins image on Openshift 4.3 and now it works, so I will close this one and keep other issue for OKD 3.11 as I have different issues with that one.

fabstao
  • 9
  • 1
  • 6
0

Your agent can't connect your jenkins by http://jenkins-gtsmex-toks1.toks1.default.svc.cluster.local/

please confirm your service is 'jenkins-gtsmex-toks1.toks1.default.svc.cluster.local' and service port is 80

jenkins default port is 8080

Miffa Young
  • 107
  • 4