<p>I have a microservices with nodejs and mysql and I'm a few days trying to use this application in kubernetes with scalability. I converted each service to an image of a POD, in fact I have a gateway that applies TCP traffic to each service. My problem is that when I run a port-forward for each pod: <strong>kubectl port-forward my-gateway --address 192.168.18.x 3000</strong> and <strong>kubectl port-forward my-adm-contact --address 192.168.18.x 8181</strong> this works normally but how I can't do a <strong>port-forward</strong> to multiple pods in a single command I decided to use NGINX Ingress Controller I installed it with helm but it only gives 404 Not Found on the page. I will put my structure below</p>
<p>followed my gateway:</p>
<pre><code>import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { AppService } from './app.service';

@Module({
  imports: [
    ClientsModule.register([
      {
        name: 'SERVICE_A',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8888,
        },
      },
      {
        name: 'SERVICE_B',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8889,
        },
      },
      {
        name: 'USER',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8887,
        },
      },
      {
        name: 'USER_LOGIN',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8886,
        },
      },
      {
        name: 'USER_CREATE',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8885,
        },
      },
      {
        name: 'USER_UPDATE',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8884,
        },
      },
      {
        name: 'CATEGORY',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8883,
        },
      },
      {
        name: 'CATEGORY_BUSCA',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8882,
        },
      },
      {
        name: 'CATEGORY_PRODUCT',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8881,
        },
      },
      {
        name: 'USER_SENHA',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8880,
        },
      },
      {
        name: 'ADM_CONTACT',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8181,
        },
      },
      {
        name: 'LOCATION',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8878,
        },
      },
      {
        name: 'PRODUCT_STAR',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8877,
        },
      },
      {
        name: 'PRODUCT_SINGLE',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8876,
        },
      },
      {
        name: 'PRODUCT_GET_STAR',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8875,
        },
      },
      {
        name: 'PURCHASE_CREATE',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8874,
        },
      },
      {
        name: 'PURCHASE_GET_CART',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8873,
        },
      },
      {
        name: 'PURCHASE_GET',
        transport: Transport.TCP,
        options: {
          host: &quot;192.168.18.x&quot;,
          port: 8870,
        },
      }
    ]),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
</code></pre>
<p>contact service:</p>
<pre><code>import { NestFactory } from '@nestjs/core';
import { Transport } from '@nestjs/microservices';
import { AppModule } from './app.module';
import { Logger } from '@nestjs/common';

const logger = new Logger();

async function bootstrap() {
  const app = await NestFactory.createMicroservice(AppModule, {
    transport: Transport.TCP,
    options: {
      host: &quot;0.0.0.0&quot;,
      port: 8181,
    },
  });
  app.listen(() =&gt; logger.log('Microservice ADM CONTACT is listening'));
}
bootstrap();
</code></pre>
<p>kubernetes service contact:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: my-adm-contact-service
  namespace: default
spec:
  ports:
  - port: 8181
    protocol: TCP
    targetPort: 8181
</code></pre>
<p>kubernetes POD contact:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: my-adm-contact
  labels:
    app: my-adm-contact
    name: my-adm-contact
spec:
  containers:
  - image: my-adm-contact
    imagePullPolicy: Never
    name: my-adm-contact
    ports:
    - containerPort: 8181
      protocol: TCP
  restartPolicy: Always
</code></pre>
<p>kubernetes endpoints contact:</p>
<pre><code>apiVersion: v1
kind: Endpoints
metadata:
  name: my-adm-contact-service
subsets:
  - addresses:
      - ip: 192.168.18.x
    ports:
      - port: 8181
</code></pre>
<p>kubernetes service gateway:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name:  my-gateway-service
  namespace: default
spec:
  ports:
  - port: 3000
    protocol: TCP
    targetPort: 3000
</code></pre>
<p>kubernetes POD gateway:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: my-gateway
  labels:
    app: my-gateway
    name: my-gateway
spec:
  containers:
  - image: api-gateway
    imagePullPolicy: Never
    name: my-gateway
    ports:
    - containerPort: 3000
      protocol: TCP
  restartPolicy: Always
</code></pre>
<p>kubernetes endpoints gateway:</p>
<pre><code>apiVersion: v1
kind: Endpoints
metadata:
  # the name here should match the name of the Service
  name: my-gateway-service
subsets:
  - addresses:
      - ip: 192.168.18.x
    ports:
      - port: 3000
</code></pre>
<p>kubernetes ingress:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web-ingress
  namespace: default
spec:
  ingressClassName: nginx
#  defaultBackend:
#    service:
#      name: my-gateway-service
#      port:
#        number: 3000
  rules:
  - host: host.docker.internal
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-gateway-service
            port:
              number: 3000
      - path: /adm-contact
        pathType: Prefix
        backend:
          service:
            name: my-adm-contact-service
            port:
              number: 8181


     
</code></pre>
<p>my ingress-nginx-tcp:</p>
<pre><code>apiVersion: v1
data:
  &quot;3000&quot;: default/my-gateway-service:3000
  &quot;8181&quot;: default/my-adm-contact-service:8181
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: ingress-nginx
    meta.helm.sh/release-namespace: ingress-nginx
  creationTimestamp: &quot;2022-06-28T00:00:28Z&quot;
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/instance: ingress-nginx
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
    app.kubernetes.io/version: 1.2.1
    helm.sh/chart: ingress-nginx-4.1.4
  name: ingress-nginx-tcp
  namespace: ingress-nginx
  resourceVersion: &quot;264565&quot;
  uid: 2284f6eb-53f9-4d8c-9f62-6ad303120f63
</code></pre>
<p>Does anyone know how to help me?</p>

Rafael Souza
<p>Is there a specific reason you've set the <code>ImagePullPolicy</code> to <code>Never</code> in your pod specifications? Perhaps try leaving it to default and remove that.</p>
<p>Also, did you ensure that your services are running fine in the cluster? You can try to bypass the <code>ingress</code> temporarily, and try to access the services directly from outside your cluster by setting the service type to <code>NodePort</code><a href="https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport" rel="nofollow noreferrer">see docs here</a> and using <code>&lt;Node-IP&gt;:&lt;nodePort&gt;</code> to access it. Just to verify the problem is not in the service backend itself? It appears to me that, that is the issue here.</p>
