<p>I'm running Jenkins using docker container and accessing it on localhost:8080 using following command:</p>
<pre class="lang-sh prettyprint-override"><code>sudo docker run --name uditgauravtest11 -p 8085:8080 -v /var/run/docker.sock:/var/run/docker.sock uditgaurav/test:1
</code></pre>
<p>Now I've accessed the Jenkins web UI at http://localhost:8080</p>
<p>I'm setting up a pipeline using this git repo <a href="https://github.com/uditgaurav/jenkins-template" rel="nofollow noreferrer">https://github.com/uditgaurav/jenkins-template</a></p>
<p>here the pipeline uses Kubernetes YAML to run as part of the job for which I configured a separate GKE cluster and connected it to the Jenkins using <code>Manage Jenkins &gt; Manage Node and Cloud &gt; Configure Jenkins</code></p>
<p>Now when I trigger the Jenkins Job It starts one slave pod on the GKE cluster which have two containers one <code>jnlp</code> container running with <code>jenkins/inbound-agent:4.3-4</code> image and another one which I mention in the Git repo pod-delete.yml (<a href="https://github.com/uditgaurav/jenkins-template" rel="nofollow noreferrer">https://github.com/uditgaurav/jenkins-template</a>)</p>
<p>But the <code>jnlp</code> container immediately goes into a failed state after coming to a running state with the following error and the pod gets terminated and a new pod comes up.</p>
<p>command:</p>
<pre><code># &quot;docker-test-68-xwmvf-b6w6f-fmpd2&quot; is the slave pod created on the cluster
kubectl logs -f docker-test-68-xwmvf-b6w6f-fmpd2  -c jnlp
</code></pre>
<p>error:</p>
<pre><code>Jan 10, 2021 2:40:20 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: docker-test-68-xwmvf-b6w6f-fmpd2
Jan 10, 2021 2:40:20 PM hudson.remoting.jnlp.Main$CuiListener &lt;init&gt;
INFO: Jenkins agent is running in headless mode.
Jan 10, 2021 2:40:20 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 4.3
Jan 10, 2021 2:40:20 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /home/jenkins/agent/remoting as a remoting work directory
Jan 10, 2021 2:40:20 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to /home/jenkins/agent/remoting
Jan 10, 2021 2:40:20 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [http://localhost:8080/]
Jan 10, 2021 2:40:20 PM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: Failed to connect to http://localhost:8080/tcpSlaveAgentListener/: Connection refused (Connection refused)
java.io.IOException: Failed to connect to http://localhost:8080/tcpSlaveAgentListener/: Connection refused (Connection refused)
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:217)
    at hudson.remoting.Engine.innerRun(Engine.java:693)
    at hudson.remoting.Engine.run(Engine.java:518)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:607)
    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.&lt;init&gt;(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:1226)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:990)
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:214)
    ... 2 more
</code></pre>
<p>The Console Output from Jenkins jobs shows that it continuously creates and deletes the same pod due to this error.</p>
<p>Console Output:</p>
<pre><code>Started by user unknown or anonymous
Obtained Jenkinsfile from git https://github.com/uditgaurav/jenkins-template
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] readTrusted
Obtained pod-delete.yaml from git https://github.com/uditgaurav/jenkins-template
[Pipeline] podTemplate
[Pipeline] {
[Pipeline] node
Created Pod: kubernetes default/docker-test-68-xwmvf-b6w6f-xbng8
[Normal][default/docker-test-68-xwmvf-b6w6f-xbng8][Scheduled] Successfully assigned default/docker-test-68-xwmvf-b6w6f-xbng8 to gke-cluster-1-default-pool-57712ddb-q2j7
[Normal][default/docker-test-68-xwmvf-b6w6f-xbng8][Pulling] Pulling image &quot;litmuschaos/chaos-ci-lib:v0.3.0&quot;
[Normal][default/docker-test-68-xwmvf-b6w6f-xbng8][Pulled] Successfully pulled image &quot;litmuschaos/chaos-ci-lib:v0.3.0&quot;
[Normal][default/docker-test-68-xwmvf-b6w6f-xbng8][Created] Created container pod-delete
[Normal][default/docker-test-68-xwmvf-b6w6f-xbng8][Started] Started container pod-delete
[Normal][default/docker-test-68-xwmvf-b6w6f-xbng8][Pulled] Container image &quot;jenkins/inbound-agent:4.3-4&quot; already present on machine
[Normal][default/docker-test-68-xwmvf-b6w6f-xbng8][Created] Created container jnlp
[Normal][default/docker-test-68-xwmvf-b6w6f-xbng8][Started] Started container jnlp
Still waiting to schedule task
‘Jenkins’ doesn’t have label ‘docker_test_68-xwmvf’
Created Pod: kubernetes default/docker-test-68-xwmvf-b6w6f-26sxm
[Normal][default/docker-test-68-xwmvf-b6w6f-26sxm][Scheduled] Successfully assigned default/docker-test-68-xwmvf-b6w6f-26sxm to gke-cluster-1-default-pool-57712ddb-q2j7
[Normal][default/docker-test-68-xwmvf-b6w6f-26sxm][Pulling] Pulling image &quot;litmuschaos/chaos-ci-lib:v0.3.0&quot;
[Normal][default/docker-test-68-xwmvf-b6w6f-26sxm][Pulled] Successfully pulled image &quot;litmuschaos/chaos-ci-lib:v0.3.0&quot;
[Normal][default/docker-test-68-xwmvf-b6w6f-26sxm][Created] Created container pod-delete
[Normal][default/docker-test-68-xwmvf-b6w6f-26sxm][Started] Started container pod-delete
[Normal][default/docker-test-68-xwmvf-b6w6f-26sxm][Pulled] Container image &quot;jenkins/inbound-agent:4.3-4&quot; already present on machine
[Normal][default/docker-test-68-xwmvf-b6w6f-26sxm][Created] Created container jnlp
[Normal][default/docker-test-68-xwmvf-b6w6f-26sxm][Started] Started container jnlp
Created Pod: kubernetes default/docker-test-68-xwmvf-b6w6f-dgx3x
[Normal][default/docker-test-68-xwmvf-b6w6f-dgx3x][Scheduled] Successfully assigned default/docker-test-68-xwmvf-b6w6f-dgx3x to gke-cluster-1-default-pool-57712ddb-q2j7
[Normal][default/docker-test-68-xwmvf-b6w6f-dgx3x][Pulling] Pulling image &quot;litmuschaos/chaos-ci-lib:v0.3.0&quot;
[Normal][default/docker-test-68-xwmvf-b6w6f-dgx3x][Pulled] Successfully pulled image &quot;litmuschaos/chaos-ci-lib:v0.3.0&quot;
[Normal][default/docker-test-68-xwmvf-b6w6f-dgx3x][Created] Created container pod-delete
[Normal][default/docker-test-68-xwmvf-b6w6f-dgx3x][Started] Started container pod-delete
[Normal][default/docker-test-68-xwmvf-b6w6f-dgx3x][Pulled] Container image &quot;jenkins/inbound-agent:4.3-4&quot; already present on machine
[Normal][default/docker-test-68-xwmvf-b6w6f-dgx3x][Created] Created container jnlp
[Normal][default/docker-test-68-xwmvf-b6w6f-dgx3x][Started] Started container jnlp
Created Pod: kubernetes default/docker-test-68-xwmvf-b6w6f-fmpd2
[Normal][default/docker-test-68-xwmvf-b6w6f-fmpd2][Scheduled] Successfully assigned default/docker-test-68-xwmvf-b6w6f-fmpd2 to gke-cluster-1-default-pool-57712ddb-9j14
[Normal][default/docker-test-68-xwmvf-b6w6f-fmpd2][Pulling] Pulling image &quot;litmuschaos/chaos-ci-lib:v0.3.0&quot;
[Normal][default/docker-test-68-xwmvf-b6w6f-fmpd2][Pulled] Successfully pulled image &quot;litmuschaos/chaos-ci-lib:v0.3.0&quot;
[Normal][default/docker-test-68-xwmvf-b6w6f-fmpd2][Created] Created container pod-delete
[Normal][default/docker-test-68-xwmvf-b6w6f-fmpd2][Started] Started container pod-delete
[Normal][default/docker-test-68-xwmvf-b6w6f-fmpd2][Pulled] Container image &quot;jenkins/inbound-agent:4.3-4&quot; already present on machine
[Normal][default/docker-test-68-xwmvf-b6w6f-fmpd2][Created] Created container jnlp
[Normal][default/docker-test-68-xwmvf-b6w6f-fmpd2][Started] Started container jnlp
</code></pre>
<p>I the gone through some similar issues and tried to resolve them for which I provided different values in <code>Dashboard &gt; Configure Global Security </code> in TCP port for inbound agents. I kept it fixed with 50000 but it is still occurring. Now I changed it to Random but it doesn't resolve the issue.</p>
<p><a href="https://i.stack.imgur.com/bCGn6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bCGn6.png" alt="enter image description here" /></a></p>
<p>Any help on this?
Please let me know If I need to share some more information.</p>

UDIT GAURAV
<p>ERROR: SEVERE: Failed to connect to http://localhost:8080/tcpSlaveAgentListener/: Connection refused (Connection refused)</p>
<p>First, ensure your GKE cluster can connected to your Jenkins master host's 50000 TCP port.(telnet 12.12.12.12 50000)</p>
<p>Your agent Failed to connect to the Jenkins master, if they not on same host, you need to setting up the &quot;Jenkins URL&quot; (Manage Jenkins &gt; Manage Node and Cloud &gt; Configure Jenkins -&gt; Kubernetes) like &quot;http://12.12.12.12:8080&quot;</p>
