<p>I have a grpc service, here is the yaml:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: staging
  labels:
    app: staging
spec:
  replicas: 4
  selector:
    matchLabels:
      app: staging
  template:
    metadata:
      labels:
        app: staging
    spec:
      containers:
      - name: staging
        image: ...
        imagePullPolicy: Always

        ports:
        - containerPort: 5274
        - containerPort: 5900
---
apiVersion: v1
kind: Service
metadata:
  name: staging-service
spec:
  type: NodePort
  selector:
    app: staging
  ports:
    - name: staging
      protocol: TCP
      port: 5274
      targetPort: 5274
      nodePort: 30277
    - name : staging
      protocol: TCP
      port: 5900
      targetPort: 5900
      nodePort: 30278
</code></pre>
<p>As you can see, the grpc is on 5900 port, now I have a ingres yaml:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: k8s-rpc-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/backend-protocol: &quot;GRPC&quot;
spec:
  ingressClassName: nginx
  rules:
    -http:
      paths:
      - path: /st(/|$)(.*)
        pathType: Prefix
        backend:
              service:
                name: staging-service
                port:
                  number: 5900
</code></pre>
<p>now, the k8s master is 192.168.70.1, so if I access 192.168.70.1/st in my nestjs project like:</p>
<pre><code>    url: ‘192.168.70.1/st’,
    package: ‘test’,
</code></pre>
<p>I will get the error:</p>
<pre><code>details: ‘Name resolution failed for target dns:192.168.70.1/st’,
</code></pre>
<p>if I access the grpc service via 192.168.70.1:30378 everything is fine.</p>
<p>Am I missing something here?</p>
<p>Thank you</p>

<p>gRPC supports DNS as the default name-system.The following format is supported which is related to IPV4 address.</p>
<p><strong>ipv4:address[:port][,address[:port],...] -- IPv4 addresses</strong></p>
<p>Here,you can specify multiple comma-delimited addresses of the form <strong>address[:port]:</strong></p>
<p><strong>address</strong> is the IPv4 address to use.</p>
<p><strong>port</strong> is the port to use. If not specified, 443 is used.</p>
<p>This is the reason you are able to access the grpc service via 192.168.70.1:30378</p>
<p>You can refer the <a href="https://github.com/grpc/grpc/blob/master/doc/naming.md" rel="nofollow noreferrer">link</a> for more useful information.</p>
