<p>I'm trying to use the Jenkins/Kubernetes plugin to orchestrate docker slaves with Jenkins. </p>

<p>I'm using this plugin:  <a href="https://github.com/jenkinsci/kubernetes-plugin" rel="noreferrer">https://github.com/jenkinsci/kubernetes-plugin</a></p>

<p>My problem is that all the slaves are offline so the job can't execute:</p>

<p><a href="https://i.stack.imgur.com/2dLZc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2dLZc.png" alt="Slave status"></a></p>

<p><a href="https://i.stack.imgur.com/Go4Sw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Go4Sw.png" alt="enter image description here"></a></p>

<p>I have tried this on my local box using minikube, and on a K8 Cluster hosted by our ops group.  I've tried both Jenkins 1.9 and Jenkins 2.  I always get the same result.  The screenshots are from Jenkins 1.642.4, K8 v1.2.0</p>

<p>Here is my configuration... note that when I click 'test connection' I get a success.  Also note I didn't need any credentials (this is the only difference I can see vs the documented example).</p>

<p><a href="https://i.stack.imgur.com/9gcxQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9gcxQ.png" alt="Jenkins System Configuration"></a></p>

<p>The Jenkins log shows the following over and over:</p>

<pre><code>    Waiting for slave to connect (11/100): docker-6b55f1b7fafce
Jul 20, 2016 5:01:06 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud$ProvisioningCallback call
Waiting for slave to connect (12/100): docker-6b55f1b7fafce
Jul 20, 2016 5:01:07 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud$ProvisioningCallback call
Waiting for slave to connect (13/100): docker-6b55f1b7fafce
Jul 20, 2016 5:01:08 PM INFO org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud$ProvisioningCallback call
</code></pre>

<p>When I run <code>kubectl get events</code> I see this:</p>

<pre><code>24s         24s        1         docker-6b3c2ff27dad3   Pod                                Normal    Scheduled           {default-scheduler }      Successfully assigned docker-6b3c2ff27dad3 to 96.xxx.xx.159
24s         23s        2         docker-6b3c2ff27dad3   Pod                                Warning   MissingClusterDNS   {kubelet 96.xxx.xx.159}   kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.
23s         23s        1         docker-6b3c2ff27dad3   Pod       spec.containers{slave}   Normal    Pulled              {kubelet 96.xxx.xx.159}   Container image "jenkinsci/jnlp-slave" already present on machine
23s         23s        1         docker-6b3c2ff27dad3   Pod       spec.containers{slave}   Normal    Created             {kubelet 96.xxx.xx.159}   Created container with docker id 82fcf1bd0328
23s         23s        1         docker-6b3c2ff27dad3   Pod       spec.containers{slave}   Normal    Started             {kubelet 96.xxx.xx.159}   Started container with docker id 82fcf1bd0328
</code></pre>

<p>Any ideas?</p>

<p>UPDATE:  more log info as suggested by csanchez</p>

<pre><code> ➜  docker git:(master) ✗ kubectl get pods --namespace default -o wide
NAME                   READY     STATUS    RESTARTS   AGE       NODE
docker-6bb647254a2a4   1/1       Running   0          1m        96.x.x.159

➜  docker git:(master) ✗ kubectl log docker-6bafbac10b392

    Jul 20, 2016 6:45:10 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to 96.x.x.159:50000 (retrying:10)
java.net.ConnectException: 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)
</code></pre>

<p>I'll have to look at what this port 50000 is used for??</p>

<p>I just want to add a bit more explanation to the above answers for newbies.</p>

<p>While exposing the jenkins UI, you also need to expose internal port 50000
Here is a simple service for a jenkins deployment:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: jenkins
  namespace: jenkins
spec:
  type: NodePort
  ports:
    - port: 8080
      name: "http"
      nodePort: 30000
      targetPort: 8080
    - port: 50000
      name: "slave"
      nodePort: 30010
      targetPort: 50000
  selector:
    app: jenkins
</code></pre>

<p>For external access to the Jenkins UI, <code>nodePort</code> is being used in the above configuration. I'm exposing port 8080 to the nodePort 30000 (jenkins UI will now available at node_ip:30000) and exposing pod port 50000 to nodeport 30010.</p>

<p>Once the svc is created:</p>

<pre><code>$ kubectl get svc -n jenkins
NAME      CLUSTER-IP    EXTERNAL-IP   PORT(S)                          AGE
jenkins   10.233.5.94   &lt;nodes&gt;       8080:30000/TCP,50000:30010/TCP   23m
</code></pre>

<p>Now add <code>jenkins_ip:30010</code> as <code>Jenkins Tunnel</code>.</p>
