title: Unable to connect with gRPC when deployed with kubernetes
body: <p>I'm trying to deploy a gRPC server with kubernetes, and connect to it outside the cluster.
  The relevant part of the server:</p>
  <pre><code>function main() {
    var hello_proto = grpc.loadPackageDefinition(packageDefinition).helloworld;
    var server = new grpc.Server();
    server.addService(hello_proto.Greeter.service, {sayHello: sayHello});
    const url = '0.0.0.0:50051'
    server.bindAsync(url, grpc.ServerCredentials.createInsecure(), () =&gt; {
      server.start();
      console.log(&quot;Started server! on &quot; + url);
    });
  }
  
  function sayHello(call, callback) {
    console.log('Hello request');
    callback(null, {message: 'Hello ' + call.request.name + ' from ' + require('os').hostname()});
  }
  </code></pre>
  <p>And here is the relevant part of the client:</p>
  <pre><code>function main() {
    var target = '0.0.0.0:50051';
    let pkg = grpc.loadPackageDefinition(packageDefinition);
    let Greeter = pkg.helloworld[&quot;Greeter&quot;];
    var client = new Greeter(target,grpc.credentials.createInsecure());
    var user = &quot;client&quot;;
    
    client.sayHello({name: user}, function(err, response) {
      console.log('Greeting:', response.message);
    });
  }
  </code></pre>
  <p>When I run them manually with nodeJS, as well as when I run the server in a docker container (client is still run with node without a container) it works just fine.</p>
  <p>The docker file with the command: <code>docker run -it -p 50051:50051 helloapp</code></p>
  <pre><code>FROM node:carbon
   
  # Create app directory
  WORKDIR /usr/src/appnpm 
   
  COPY package.json .
  COPY package-lock.json .
   
  RUN npm install
   
  COPY . .
   
  CMD npm start
  </code></pre>
  <p>However, when I'm deploying the server with kubernetes (again, the client isnt run within a container) I'm not able to connect.</p>
  <p>The yaml file is as follows:</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: helloapp
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: helloapp
    strategy: {}
    template:
      metadata:
        labels:
          app: helloapp
      spec:
        containers:
          image: isolatedsushi/helloapp
          name: helloapp
          ports:
          - containerPort: 50051
            name: helloapp
          resources: {}
  status: {}
  ---
  apiVersion: v1
  kind: Service
  metadata:
    name: helloservice
  spec:
    selector:
      app: helloapp
    ports:
    - name: grpc
      port: 50051
      targetPort: 50051
  </code></pre>
  <p>The deployment and the service start up just fine</p>
  <pre><code>kubectl get svc
  NAME           TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)     AGE
  helloservice   ClusterIP   10.105.11.22   &lt;none&gt;        50051/TCP   17s
  
  
  kubectl get pods      
  NAME                     READY   STATUS    RESTARTS   AGE
  helloapp-dbdfffb-brvdn   1/1     Running   0          45s
  </code></pre>
  <p>But when I run the client it can't reach the server.</p>
  <p>Any ideas what I'm doing wrong?</p>