<p>I found <a href="https://devopscube.com/jenkins-build-agents-kubernetes/" rel="nofollow noreferrer">a detailed guide</a> which lead me to the answer...</p>
<p>In the service section only port 8080 was forwarded to 32000.</p>
<p>So I changed the service.yaml to be</p>
<pre class="lang-yml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: jenkins-service
  namespace: devops-tools
  annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/path:   /
      prometheus.io/port:   '8080'
spec:
  selector:
    app: jenkins-server
  type: NodePort
  ports:
    - name: httpport
      port: 8080
      targetPort: 8080
      nodePort: 32000
    - name: jnlpport
      port: 50000
      targetPort: 50000
</code></pre>
<p>and executed <code>kubectl apply -f service.yaml</code> which seems to have had an immediate effect.</p>

CC BY-SA 4.0
2023-01-11T21:59:13.720Z
2023-01-11T21:59:13.720Z
JoSSte
<p>I am setting up a k8s cluster using k3s. Currently I have a <a href="https://hub.docker.com/r/jenkins/jenkins" rel="nofollow noreferrer">Jenkins pod</a> running, set up according to <a href="https://www.jenkins.io/doc/book/installing/kubernetes/" rel="nofollow noreferrer">this guide</a>.</p>
<p>I have run into an issue <a href="https://chathura-siriwardhana.medium.com/configure-jenkins-with-kubernetes-e3175e02ca8" rel="nofollow noreferrer">setting up the kubernetes cluster for Jenkins workers</a> I can't seem to get my head wrapped around:</p>
<p>If I go to my Jenkins pod and start the console to test that the JNLP is working, not all the different names I can use work:</p>
<p><code>curl localhost:50000</code> ✔ Works<br />
<code>curl `cat /etc/hostname`:50000</code> ✔ Works<br />
<code>curl jenkins-service:50000</code> ❌ Times out</p>
<p><strong>BUT !!!</strong></p>
<p><code>curl localhost:8080</code> ✔ Works<br />
<code>curl `cat /etc/hostname`:8080</code> ✔ Works<br />
<code>curl jenkins-service:8080</code> ✔ Works</p>
<p>I then went back to the YAML and took a look at it. Appart from there being more references to 8080 than 50000 (8080 is a part of several urls and liveliness checks and so on), I do not see anything amiss</p>
<pre class="lang-yml prettyprint-override"><code>      containers:
        ...
        ports:
        - containerPort: 8080
          name: httpport
          protocol: TCP
        - containerPort: 50000
          name: jnlpport
          protocol: TCP
</code></pre>
<p>I have looked at <a href="https://github.com/jenkinsci/docker-inbound-agent/issues/146" rel="nofollow noreferrer">these</a> <a href="https://github.com/jenkinsci/docker/issues/788" rel="nofollow noreferrer">defects</a> and the issues seem to not be the same, causing me to think that it must be Kubernetes related.</p>

<kubernetes><jenkins>
Kubernetes internal network and addresses not working for all internal names for same pod/service
JoSSte
# Kubernetes internal network and addresses not working for all internal names for same pod/service

(Asked by: username_0 on 2023-01-11)

I am setting up a k8s cluster using k3s. Currently I have a Jenkins pod running, set up according to this guide.
I have run into an issue setting up the kubernetes cluster for Jenkins workers I can't seem to get my head wrapped around:
If I go to my Jenkins pod and start the console to test that the JNLP is working, not all the different names I can use work:
curl localhost:50000 ✔ Works
curl `cat /etc/hostname`:50000 ✔ Works
curl jenkins-service:50000 ❌ Times out
BUT !!!
curl localhost:8080 ✔ Works
curl `cat /etc/hostname`:8080 ✔ Works
curl jenkins-service:8080 ✔ Works
I then went back to the YAML and took a look at it. Appart from there being more references to 8080 than 50000 (8080 is a part of several urls and liveliness checks and so on), I do not see anything amiss
      containers:
        ...
        ports:
        - containerPort: 8080
          name: httpport
          protocol: TCP
        - containerPort: 50000
          name: jnlpport
          protocol: TCP

I have looked at these defects and the issues seem to not be the same, causing me to think that it must be Kubernetes related.

**Tags:** kubernetes, jenkins


---

## 1 answers

### Answer by username_0 on 2023-01-11. Score: 0 | Accepted answer

I found a detailed guide which lead me to the answer...
In the service section only port 8080 was forwarded to 32000.
So I changed the service.yaml to be
apiVersion: v1
kind: Service
metadata:
  name: jenkins-service
  namespace: devops-tools
  annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/path:   /
      prometheus.io/port:   '8080'
spec:
  selector:
    app: jenkins-server
  type: NodePort
  ports:
    - name: httpport
      port: 8080
      targetPort: 8080
      nodePort: 32000
    - name: jnlpport
      port: 50000
      targetPort: 50000

and executed kubectl apply -f service.yaml which seems to have had an immediate effect.


---

