Jenkins JLNP agent not responding

2/5/2020

I am trying to use jenkins and kubernetesplugin. I deployed a kubernetes cluster in AWS using kubeadm and I installed jenkins on a EC2 VM.

I am trying to initiate the deployment of pods in the kubernetes clusters using pipelines in jenkins.

However I keep getting an agent time out:

Waiting for agent to connect (30/100): mypod-67j9m-nqz0g
Feb 05, 2020 6:30:39 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher launch
Container is terminated mypod-67j9m-nqz0g [jnlp]: ContainerStateTerminated(containerID=docker://8021b8da7c087efd6c84085032c56b5523ca7492332e441fa302a561b93b9829, exitCode=255, finishedAt=2020-02-05T18:30:38Z, message=null, reason=Error, signal=null, startedAt=2020-02-05T18:30:07Z, additionalProperties={})
Feb 05, 2020 6:30:39 PM SEVERE org.csanchez.jenkins.plugins.kubernetes.KubernetesLauncher logLastLines
Error in provisioning; agent=KubernetesSlave name: mypod-67j9m-nqz0g, template=PodTemplate{, name='mypod-67j9m', label='mypod', nodeUsageMode=EXCLUSIVE, workspaceVolume=EmptyDirWorkspaceVolume [memory=false], containers=[ContainerTemplate{name='golang', image='golang:1.8.0', command='cat', ttyEnabled=true}], annotations=[org.csanchez.jenkins.plugins.kubernetes.PodAnnotation@aab9c821]}. Container jnlp exited with error 255. Logs: Feb 05, 2020 6:30:08 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to /home/jenkins/agent/remoting
Feb 05, 2020 6:30:08 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://ec2-18-140-64-62.ap-southeast-1.compute.amazonaws.com:8080/]
Feb 05, 2020 6:30:38 PM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: Failed to connect to http://xxxxx.ap-southeast-1.compute.amazonaws.com:8080/tcpSlaveAgentListener/: connect timed out

My pod is running but there is no response from the slave pod and the message states that

JNLP agent port is disabled and agents cannot connect this way

this is my current set up

podTemplate(cloud: 'kubernetes', label: 'mypod',containers: [
    containerTemplate(name: 'golang', image: 'golang:1.8.0', ttyEnabled: true, command: 'cat')
  ]) {

    node('mypod') {

        stage('Get a Golang project') {
            git url: 'https://github.com/hashicorp/terraform.git'
            container('golang') {
                stage('Build a Go project') {
                    sh 'echo hello world'
                }
            }
        }

    }
}

enter image description here

-- Adam
jenkins
kubernetes

1 Answer

2/5/2020

The slave connects back to Jenkins via JNLP on JNLP port (TCP port for incoming agents). If you will go to Manage > Configure Global Security; you would be able to see that; select Fixed port and specify a value say 50000.

-- Pankaj
Source: StackOverflow