<p>I have created 2 services and for each of the service there is a corresponding deployment. All these are in the same PC. After applying the YAML, the services and deployments are running properly.</p>
<pre><code>sudo npm kubectl apply -f deployment.yaml
</code></pre>
<p>Now, if I try to curl to the ingress IP address, then I get 404 page not found as the response.</p>
<pre><code>sudo kubectl get ingress -o wide
sudo curl &lt;IP address of ingress&gt;
</code></pre>
<p>If I try to curl to the IP address of the employee service or employee deployment, it gives that the connection was refused after waiting for sometime. Which ever port I mentioned for the employee service and deployment I try, I always get error instead of the proper response.</p>
<p>Can someone from the community please assist. I need to call the <code>/emplist</code> endpoint of myshop pod from employee pod.</p>
<p>myshop.js</p>
<pre><code>const express = require('express')
const app = express()
const port = 3000

app.get('/emplist', (req, res) =&gt; {
    res.status(200).send( empListObj )
});

app.listen(port, '0.0.0.0', () =&gt; {
  console.log(`Listening on port ${port}`)
})
</code></pre>
<p>employee.js</p>
<pre><code>const axios = require('axios').default;

const express = require('express')
const app = express()
const port = 3001

app.get('/', (req, res) =&gt; {
  
  axios({
      method: 'get',
      url: 'http://myshopservice/emplist'
    })
    .then(function (response) {
        res.status(200).send(response.data.empList)
    })
    .catch(function (error) {
        res.status(200).send(`Error because ${error}`);
    })
})

app.listen(port, '0.0.0.0', () =&gt; {
  console.log(`Listening on port ${port}`)
})
</code></pre>
<p>Now the corresponding deployment.yaml is:</p>
<pre><code>---
apiVersion: networking.k8s.io/v1 
kind: Ingress 
metadata: 
  name: myshop-ingress 
  annotations: 
    nginx.ingress.kubernetes.io/rewrite-target: / 
spec: 
  rules: 
  - host: myshop.com 
    http: 
      paths: 
      - path: / 
        pathType: Prefix 
        backend: 
          service: 
            name: myshopservice 
            port: 
              number: 4000 

---

apiVersion: v1
kind: Service
metadata:
  name: myshopservice
spec:
  selector:
    app: myshop
  ports:
    - protocol: &quot;TCP&quot;
      port: 4000
      targetPort: 3000
      nodePort: 30000
  type: LoadBalancer

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myshop
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myshop
  template:
    metadata:
      labels:
        app: myshop
    spec:
      containers:
        - name: myshop
          image: mydockerhubid/myshop:1
          ports:
            - containerPort: 3000

---
apiVersion: v1
kind: Service
metadata:
  name: employeeservice
spec:
  selector:
    app: employee
  ports:
    - protocol: &quot;TCP&quot;
      port: 4001
      targetPort: 3001
      nodePort: 30001
  type: LoadBalancer

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: employee
spec:
  replicas: 1
  selector:
    matchLabels:
      app: employee
  template:
    metadata:
      labels:
        app: employee
    spec:
      containers:
        - name: hud
          image: mydockerhubid/employee:1
          ports:
            - containerPort: 3001

---
</code></pre>

Soumya
<p>Looks like there is issue with ingress mainly. i would suggest first to check the services status if it's running or not at <code>&lt;Loadbalancer IP:Port/path&gt;</code> <strong>(Both services)</strong></p>
<p>Your app is listening on one specific path but you are not requesting that path in <strong>curl</strong>. If you want to do it that way you can also do it however i would suggest try simple way first and thn play with route/path based routing.</p>
<p>Plus your ingress is sending requests at myshop service but it only listening or have route : <strong>/emplist</strong></p>
<p>So try once ingress by removing annotation and host as you are on local.</p>
<p>If you want to keep host you have to add entry locally into <code>/etc/hosts</code> for <strong>host</strong> and ingress <strong>IP</strong> mapping and you should be using the or try curl on domain instead ingress IP then.</p>
<p>Are you running any ingress controller? Nginx or so?  : <a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/</a></p>
<pre><code>---
apiVersion: networking.k8s.io/v1 
kind: Ingress 
metadata: 
  name: myshop-ingress 
spec: 
  rules: 
  - http: 
      paths: 
      - path: / 
        pathType: Prefix 
        backend: 
          service: 
            name: myshopservice 
            port: 
              number: 4000 
</code></pre>
<p>Check this very simple example for ingress routing and controller setup : <a href="https://dev.to/xaviergeerinck/creating-a-kubernetes-nginx-ingress-controller-and-create-a-rule-to-a-sample-application-4and" rel="nofollow noreferrer">https://dev.to/xaviergeerinck/creating-a-kubernetes-nginx-ingress-controller-and-create-a-rule-to-a-sample-application-4and</a></p>
