<p>On AWS EKS, I have three pods in a cluster each of which have been exposed by services. The problem is the services can not communicate with each other as discussed here <a href="https://stackoverflow.com/questions/71434784/error-while-doing-inter-pod-communication-on-eks">Error while doing inter pod communication on EKS</a>. It has not been answered yet but further search said that it can be done through Ingress. I am having confusion as to how to do it? Can anybody help ?</p>
<p>Code:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: test
  name: ingress-test
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
spec:
  ingressClassName: alb
  rules:
    - http:
        paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: server-service
              port:
                number: 8000
</code></pre>
<p>My server-service has APIs like /api/v1/getAll, /api/v1/updateAll, etc.
So, what should I write in path and for a database service what should I do??</p>
<p>And say in future I make another microservice and open another service which has APIs like /api/v1/showImage, /api/v1/deleteImage will I have to write all paths in ingress or is their another way for it to work?</p>

Mareek Roy
<p>A Ingress is a really good solution to expose both a frontend and a backend at the same domain with different paths (but reading your other question, it will be of no help in exposing the database)</p>
<p>With this said, you don't have to write all the paths in the Ingress (unless you want to) as you can instead use <code>pathType: Prefix</code> as it is already in your example.</p>
<p>Let me link you to the <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#examples" rel="nofollow noreferrer">documentation Examples</a> which explain how it works really well. Basically, you can add a rule with:</p>
<pre><code>path: /api
pathType: Prefix
</code></pre>
<p>In order to expose your backend under <code>/api</code> and all the child paths.</p>
<hr />
<p>The case where you put a second backend, which wants to be exposed under <code>/api</code> as the first one, is way more complex instead. If two Pods wants to be exposed at the same paths, you will probably need to list all the subpaths in a way that differentiate them.</p>
<p>For example:</p>
<p>Backed A</p>
<pre><code>/api/v1/foo/listAll
/api/v1/foo/save
/api/v1/foo/delete
</code></pre>
<p>Backend B</p>
<pre><code>/api/v1/bar/listAll
/api/v1/bar/save
/api/v1/bar/delete
</code></pre>
<p>Then you could expose one under subPath <code>/api/v1/foo</code> (Prefix) and the other under <code>/api/v1/bar</code> (Prefix).</p>
<p>As another alternative, you may want to expose the backends at different paths from what they actually expect using a <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">rewrite target rule</a>.</p>
