Unable to connect to grpc service using ingress

Cluster information:

Kubernetes version: v1.10.11
Cloud being used: (put bare-metal if not on a public cloud) bare-metal
Installation method: homebrew
Host OS: Mac

I am trying to connect to a grpc service deployed on kubernetes via ingress. Here are the config files

grpc-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: test-gservice
  namespace: default
spec:
  type: NodePort
  selector:
    k8s-app: test-gserver
  ports:
  - port: 8888
    targetPort: 8888
    nodePort: 31080
    name: grpc 

ingress-loadbalancer.yaml

kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: default
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  type: LoadBalancer 
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 9999
      targetPort: 8888

When I try to connect to localhost:9999 through a client on my local machine, I am getting the following error:
2019/11/01 10:50:37 could not greet: %vrpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection closed

and when I try to do the same with localhost:8888, I get connection refused.

But when I try to connect to the nodeport of the grpc service, I am getting the correct response.

I am new to ingress and kubernetes. I am not sure what I am doing wrong. Any help would be greatly appreciated.

I’d recommend you to spend some time with this page