<p>I am trying to put my .net core web applications into k8s.</p>
<p>I've two front end application namely:</p>
<ul>
<li>Authentication (Auth) service (using .net 3.1 identityserver4). Auth service allow user to authenticate themselves and upon successfully, Auth service shall redirect to web services with JWT token</li>
<li>Web service (using .net 5). Once user authenticate successfully, Web service receive the JWT token and create a session cookie.</li>
</ul>
<p>When deploying in Docker, both services are run with different ports and using Nginx reverse proxy and both services contains root path etc</p>
<pre><code>server {
 listen 44343
 location /
  {redirect to Auth Service}
}

server {
  listen 44345
  location /
   {redirect to Web Service}
}
</code></pre>
<p>But in k8s, it seems like I can't do that way. Hence any kind souls guide me what is the correct set up for ingress or nginx?</p>

Joseph Y
<p>You might create two services for each port and an ingress:</p>
<p><strong>authsvc.yaml</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: auth-service
spec:
  type: NodePort
  selector:
    component: web
  ports:
    - port: 44343
      targetPort: x (i guess this could be your port 80/443 because is the &quot;entry&quot;)
</code></pre>
<p><strong>webservicesvc.yaml</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: web-service
spec:
  type: NodePort
  selector:
    component: web
  ports:
    - port: 44345
      targetPort: x
</code></pre>
<p><strong>ingress.yaml</strong></p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: auth-service
            port:
              number: 44343
      - path: /
        pathType: Prefix
        backend:
          service:
            name: web-service
            port:
              number: 44345
</code></pre>
<p>/ means all paths
Also you can have a different ingress type like TLS.
Take a look at: <a href="https://www.yogihosting.com/kubernetes-ingress-aspnet-core/" rel="nofollow noreferrer">https://www.yogihosting.com/kubernetes-ingress-aspnet-core/</a></p>
