<p>I have <code>Kubernetes cluster v1.19.16</code> set up in bare metal Ubuntu-18.04 server and currently i want to connect cluster jenkins service through <code>http://jenkins.company.com</code>. Haproxy server side frontend &amp; backend already been configured.</p>
<p>My <code>service.yaml</code> file content as follows,</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: jenkins-svc
  namespace: jenkins
  annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/path:   /
      prometheus.io/port:   '8080'
spec:
  selector: 
    app: jenkins-server
  type: ClusterIP
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 80
</code></pre>
<p><code>ingress-resource.yaml</code> file content as follows,</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: jenkins-ingress
  namespace: jenkins
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
spec:
  rules:
  - host: &quot;jenkins.company.com&quot;
    http:
      paths:
      - pathType: Prefix
        path: &quot;/&quot;
        backend:
          serviceName: jenkins-svc
          servicePort: 8080
</code></pre>
<pre><code># kubectl get service -n jenkins
NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
jenkins-svc   ClusterIP   10.96.136.255   &lt;none&gt;        8080/TCP   20m
</code></pre>
<pre><code># kubectl get ing jenkins-ingress
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
NAME              CLASS    HOSTS                ADDRESS   PORTS   AGE
jenkins-ingress   &lt;none&gt;   jenkins.company.com            80      5h42m
</code></pre>
<pre><code># kubectl describe ingress  -n jenkins
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Name:             jenkins-ingress
Namespace:        jenkins
Address:
Default backend:  default-http-backend:80 (&lt;error: endpoints &quot;default-http-backend&quot; not found&gt;)
Rules:
  Host             Path  Backends
  ----             ----  --------
  jenkins.dpi.com
                   /   jenkins-svc:8080 (10.244.0.16:80)
Annotations:       ingress.kubernetes.io/rewrite-target: /
                   kubernetes.io/ingress.class: nginx
Events:            &lt;none&gt;
</code></pre>
<p>When i tried to access <code>http://jenkins.company.com</code> it shows below error message on browser.</p>
<p><a href="https://i.stack.imgur.com/i2sE2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i2sE2.png" alt="Error Message" /></a></p>
<p>Please let me know what i'm missing here?</p>

user4948798
<p>The issue with the <code>service port</code> and <code>container port</code>. Jenkins default port is <code>8080</code>, so I assume your service port is <code>80</code></p>
<pre><code>  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
</code></pre>
<p>and ingress should be</p>
<pre><code>spec:
  rules:
  - host: &quot;jenkins.company.com&quot;
    http:
      paths:
      - pathType: Prefix
        path: &quot;/&quot;
        backend:
          serviceName: jenkins-svc
          servicePort: 80
</code></pre>
<blockquote>
<p><code>port</code>: The port of this service
<code>targetPort</code> The target port on the pod(s) to forward traffic to</p>
</blockquote>
<p><a href="https://stackoverflow.com/questions/49981601/difference-between-targetport-and-port-in-kubernetes-service-definition">Difference between targetPort and port in Kubernetes Service definition</a></p>
