<p>I am building a microservice full stack web application as (so far) :</p>
<blockquote>
<p>ReactJS (client microservice) : listens on 3000</p>
</blockquote>
<blockquote>
<p>Authentication (Auth microservice) : listens on 3000 // accidently assigned the same port</p>
</blockquote>
<p>Technically, what I have heard/learned so far is that we <em>cannot have</em> two Pods running on the <em>same port</em>.
I am really confused <em>how am I able to run the application (perfectly) like this with same ports on different applications/pods?</em></p>
<p><strong>ingress-nginx config:</strong></p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata: 
    name: ingress-service 
    annotations: 
        kubernetes.io/ingress.class: nginx 
        nginx.ingress.kubernetes.io/use-regex: 'true'
spec: 
    ## our custom routing rules  
    rules: 
        - host: ticketing.dev 
          http: 
            paths:
                - path: /api/users/?(.*) 
                  backend: 
                    serviceName: auth-srv 
                    servicePort: 3000
                - path: /?(.*)
                  backend: 
                    serviceName: client-srv
                    servicePort: 3000 

</code></pre>
<p>I am really curious, am I missing something here?</p>

Karan Kumar
<p>Each Pod has its own network namespace and its own IP address, though the Pod-specific IP addresses aren't reachable from outside the cluster and aren't really discoverable inside the cluster.  Since each Pod has its own IP address, you can have as many Pods as you want all listening to the same port.</p>
<p>Each Service also has its own IP address; again, not reachable from outside the cluster, though they have DNS names so applications can find them.  Since each Service has its own IP address, you can have as many Services as you want all listening to the same port.  The Service ports can be the same or different from the Pod ports.</p>
<p>The Ingress controller is reachable from outside the cluster via HTTP.  The Ingress specification you show defines HTTP routing rules.  If I set up a DNS service with a <code>.dev</code> TLD and define an A record for <code>ticketing.dev</code> that points at the ingress controller, then <code>http://ticketing.dev/api/users/anything</code> gets forwarded to <code>http://auth-srv.default.svc.cluster.local:3000/</code> within the cluster, and <code>http://ticketing.dev/otherwise</code> goes to <code>http://client-srv.default.svc.cluster.local:3000/</code>.  Those in turn will get forwarded to whatever Pods they're connected to.</p>
<p>There's no particular prohibition against multiple Pods or Services having the same port.  I tend to like setting all of my HTTP Services to listen on port 80 since it's the standard HTTP port, even if the individual Pods are listening on port 3000 or 8000 or 8080 or whatever else.</p>
