title: Jenkins on EKS can't connect to external EC2 server as Jenkins worker-node: ERROR `port:50000 is not reachable`
body: <p>My main task is to create a Jenkins Node from an EC2 instance/server.</p>
  
  <p>Jenkins server it's on EKS deployed via <code>jx</code> </p>
  
  <pre><code>$ jx version
  
  jx                 2.0.818
  jenkins x platform 2.0.1376
  Kubernetes cluster v1.13.12
  kubectl            v1.17.0
  helm client        Client: v2.16.1
  git                2.23.0
  Operating System   Mac OS X 10.15.4
  </code></pre>
  
  <p>The problems I am facing: </p>
  
  <ul>
  <li>The Helm chart for Jenkins deploys 2 services named <code>jenkins-agent</code> and <code>jenkins</code>. <a href="https://www.gitmemory.com/issue/helm/charts/7360/498268052" rel="nofollow noreferrer">related issue</a></li>
  <li>The ingress it's configured by default to use just <code>jenkins</code> service as backend and port <code>50000</code> isn't reachable for external agents via HOST.</li>
  <li>I can't edit the <code>jenkins</code> ingress to point at service <code>jenkins</code> with 2 backend ports <code>8080</code> &amp; <code>50000</code> (ingress allows just one port per service/path!). <a href="https://github.com/kubernetes/ingress-nginx/issues/1655#issuecomment-342222762" rel="nofollow noreferrer">related issue</a></li>
  </ul>
  
  <p>You can see here that here is 2 services: 1 <code>jenkins</code> for jenkins master and one for jenkins slave <code>jenkins-agent</code>, but only one ingress <code>jenkins</code> which points to <code>jenkins</code> svc backend on port <code>8080</code>.</p>
  
  <pre><code>$ kubectl get svc
  NAME                        TYPE           CLUSTER-IP       EXTERNAL-IP    PORT(S)
  heapster                    ClusterIP       ************    &lt;none&gt;         8082/TCP
  jenkins                     ClusterIP       ************    &lt;none&gt;         8080/TCP
  jenkins-agent               ClusterIP      ************     &lt;none&gt;         50000/TCP
  jenkins-x-chartmuseum       ClusterIP      ************     &lt;none&gt;         8080/TCP
  jenkins-x-docker-registry   ClusterIP     ************      &lt;none&gt;         5000/TCP
  
  
  
  $ kubectl get ingress
  NAME              HOSTS                             ADDRESS            PORTS
  chartmuseum       chartmuseum.**                    ***.amazonaws.com   80  
  docker-registry   docker-registry.**                ***.amazonaws.com   80
  jenkins           jenkins.**                        ***.amazonaws.com   80
  </code></pre>
  
  <p>I tried to create another ingress specific for <code>jenkins-agent</code> svc and to use something like <code>alb.ingress.kubernetes.io/group.name: mygroup</code>. <a href="https://stackoverflow.com/a/58380144">info link</a></p>
  
  <p>I failed to bind 2 ingresses together, unfortunately the <code>jenkins</code> ingress has <code>kubernetes.io/ingress.class: nginx</code> and  <code>ingress.class</code> does't have this feature...</p>
  
  <p>I checked the SecurityGroups to have the port <code>50000</code> open.</p>
  
  <p>I tried to go on AWS and to add manually a <code>50000</code> port to load balancer but still when I am running on EC2 this command:</p>
  
  <pre><code>java -jar agent.jar -jnlpUrl http://JENKINS_URL/computer/****-service/slave-agent.jnlp -secret ****** -workDir "/home/ec2-user/jenkins_home" -failIfWorkDirIsMissing
  </code></pre>
  
  <p>Fails with this Error:</p>
  
  <pre><code>provided port:50000 is not reachable
  </code></pre>
  
  <p>How to add an external Jenkins Slave to a Jenkins which 2 services one for UI and Another for Agent. The above <code>java</code> command requires both ports to be open! </p>
  
  <p>On the same <code>PATH</code> because you need port 8080 to get the <code>slave-agent.jnlp</code> and after you get it, in the background it's trying to connect to port <code>50000</code> </p>
  
  <p>I am out of ideas...</p>