<p>I have deployed nginx :</p>

<pre><code>kubectl run nginx --image=nginx
</code></pre>

<p>And I exposed nginx </p>

<pre><code>kubectl expose deployment nginx --port 80 --type NodePort
</code></pre>

<p>And when execute this command</p>

<pre><code>kubectl get svc
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE

nginx        NodePort    10.254.237.40   &lt;none&gt;        80:31111/TCP   22s

jenkins      ClusterIP   10.254.118.81   &lt;none&gt;        8080/TCP       45m
</code></pre>

<p>And I deployed Ingress file</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - host: example.com
      http:
        paths:
        - path: /jenkins
          backend:
            serviceName: jenkins
            servicePort: 8080
</code></pre>

<p>And to know Output of ingress</p>

<pre><code>-&gt; kubectl apply -f ingress.yaml
ingress.extensions "nginx" configured
-&gt; kubectl get ing
NAME      HOSTS           ADDRESS   PORTS     AGE
nginx     example.com             80        40m
</code></pre>

<p>And when Browser </p>

<pre><code>http://Node-IP:31111
Returns Nginx's Welcome Page
</code></pre>

<p>And When Browser </p>

<pre><code>http://http://Node-IP:31111/jenkins
Returns 404 Not Found
</code></pre>

<p>Is there something I do not understand? </p>

<p>And How to Solve this Issue? </p>

<p>thank you :D </p>

AhmedMItman
<p>You are not supposed to use the <code>Node-IP</code> if you want to get to the jenkins endpoint. In this case, you need to use <code>example.com</code>. But you need the Layer 7 Host header so that the ingress understands it. To test it, you need to modify it. A couple of ways you can do it:</p>

<ol>
<li><p>Try running:</p>

<pre><code>curl -H 'Host: example.com' http://Node-IP:31111/jenkins
</code></pre></li>
<li><p>Modify the <code>/etc/hosts</code> to have an entry <code>Node-IP example.com</code>file on your machine and just browse to:</p>

<pre><code>http://example.com:31111/jenkins
</code></pre></li>
</ol>

<p>Note that you are using a <code>NodePort</code> for you service. You can use a <code>LoadBalancer</code> type to avoid specifying the port. (Use the default port 80). You can also use the clusterIP <code>10.254.237.40</code>, but to access it you would have to be in one the machines in your Kubernetes cluster.</p>
