<p>I'm working on a little gRCP API and I've run into a small issue. I want the gRPC service to be accessible from a React front end, which means I need to have an envoy proxy that translates gRPC -> HTTP1 and vice versa.  </p>

<p><strong>TL;DR</strong> I think I can reach the envoy proxy, but the proxy isn't routing to my service correctly.  </p>

<p>I'll put the info for the services here and explain what's happening below.  </p>

<p>K8s (deployment and service) yaml files for each of my services:<br>
<a href="https://github.com/OlamAI/Simulation/blob/v2/k8s/deployment.yaml" rel="nofollow noreferrer">Simulation deployment</a>  </p>

<p>Envoy config file and docker image<br>
<a href="https://github.com/OlamAI/Envoy-Proxy/blob/master/envoy-proxy.yaml" rel="nofollow noreferrer">Envoy Config</a><br>
<a href="https://github.com/OlamAI/Envoy-Proxy/blob/master/Dockerfile" rel="nofollow noreferrer">Envoy Dockerfile</a>  </p>

<p>Here is a quick sanity check making sure that my service works, disregarding the envoy proxy:</p>

<pre><code>&gt; kubectl get services
NAME              TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
kubernetes        ClusterIP   10.96.0.1        &lt;none&gt;        443/TCP          37d
sim-dep           NodePort    10.105.65.65     &lt;none&gt;        9090:30780/TCP   3s
sim-dep-http1     NodePort    10.111.190.170   &lt;none&gt;        8080:30948/TCP   3s
sim-envoy-proxy   NodePort    10.110.178.132   &lt;none&gt;        9091:32068/TCP   17h

&gt; curl &lt;minikube ip&gt;:30948/v1/todo/all
{"api":"v1","toDos":[{}]}

&gt; ./client-grpc -server=192.168.99.100:30780
&lt;success from server, too much to put here but it works&gt;
</code></pre>

<p>So from what I understand, this envoy proxy should accept connections on port 9091, then re-route them to the address sim-dep (K8s DNS is running) on port 9090.<br>
Here is my code and error when I run this on a React app on my host machine (not in minikube).  </p>

<pre><code>var todoService = new ToDoServiceClient(
   "http://192.168.99.100:32068/",
   null,
   null
);
var todo = new ToDo();
todo.setTitle("JS Created ToDo");
todo.setDescription("This todo was created with JS client");
var createRequest = new CreateRequest();
createRequest.setApi("v1");
createRequest.setTodo(todo);
var response = await todoService.create(createRequest, {}, &lt;callback&gt;);
</code></pre>

<p><strong>Logs:</strong></p>

<pre><code>upstream connect error or disconnect/reset before headers
</code></pre>

<p>I'm assuming this means it can't connect at some level, but that error isn't very descriptive. I also can't curl through the envoy proxy, but I did try sending a request with PostMan and got this:</p>

<p><a href="https://i.stack.imgur.com/r1ktn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r1ktn.jpg" alt="enter image description here"></a></p>

<p>I'm not too sure what to make of that, but it sort of seems like it's reaching envoy but isn't reaching the service. I would appreciate any help on this! :) And let me know if I missed any info here. Thanks!</p>

<p>Just figured it out!  </p>

<p>To debug this I ran the proxy container locally. I was able to connect to it and was getting this error:</p>

<pre><code>unknown service /v1.ToDoService
</code></pre>

<p>I hate myself for this, but that error was essentially saying this in english: </p>

<pre><code>I can connect to your server, but I can't find a service called /v1.ToDoService
</code></pre>

<p>and after a ridiculous amount of staring at my code and doing sanity checks, I realized that it was looking for the service in the wrong spot... the error really should give a bit more info but all I had to do was change the connection url in my JS client to this:</p>

<pre><code>http://localhost:32068
</code></pre>

<p><strong>No slash at the end! Whoops!</strong></p>

<p>Now to deal with deploying this proxy...  </p>

<p>So the deployment for the gRPC service has metadata on it that creates a DNS address(? not sure what its called) for the service. So in my case, I called my service <code>sim-dep</code>. If you follow the <a href="https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/" rel="nofollow noreferrer">DNS section tutorial here</a>, you can do a DNS lookup for your service which in my case gave me  </p>

<p><code>sim-dep.default.svc.cluster.local</code>.  </p>

<p>Now all I had to do after finding that was replace the host address of the envoy config to that address and everything worked out!</p>
