question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support custom path prefix in gRPC service URL

See original GitHub issue

Is your feature request related to a problem? Yes

The ask here is related to the following issue: https://github.com/grpc/grpc/issues/14900 We have following usecase:

We have multiple instances of the same gRPC server app running on multiple k8s deployments. Our routing model from gRPC client to gRPC servers is not direct but rather using Ingress with rerouting based on path

myserver/path1/myApi/call1 goes to instance1 myserver/path2/myApi/call1 goes to instance2 … myserver/pathN/myApi/call1 goes to instanceN

Now that nginx supports gRPC routing, this seems trivial to set up from the routing side. Alas, it does not seem to work. Since gRPC target and subsequently authority take only host:port into consideration

Number of destination servers is not finite as those come and go, so it’s not possible to have static Ingress spec

Possibly this is a gRPC client limitation?

Describe the solution you’d like

What we’d like to have is a way to specify path part in the target or any other header that will allow to produce HTTP2 URI that can be rerouted finalDestinationServer/myApi/call1

Describe alternatives you’ve considered

use REST instead of gRPC

Additional context

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ejona86commented, Nov 10, 2022
Metadata.Key destinationServer = Metadata.Key.of("destination-server", Metadata.ASCII_STRING_MARSHALLER)

Metadata metadata = new Metadata();
metadata.put(destinationServer, "path2");
stub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata)).someMethod();

I don’t have any snippet for k8s.

0reactions
yuliya-salesforcecommented, Nov 10, 2022

Are you using Java on both client and server

We are using Java for client and most likely Python for server

For header-based routing your client would add a piece of Metadata to the request, and then you’d configure the proxy to change the destination based on that header.

I see. So eventually it’s k8s setup of a proxy that would need to be header based If you have any Java example of the client and respective k8s setup - it would be great! (if you have it handy)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support custom path prefix in gRPC service URL · Issue #14900
I have multiple instances of my gRPC server app running on my servers. My deployment model would be greatly simplified if I could...
Read more >
GRPC address prefix - Stack Overflow
1 Answer 1 ... In a grpc service, the URL of the underlying HTTP2 request is determined by the name of the of...
Read more >
Configuring a gRPC service - Cloud Endpoints
To create a gRPC service—whether or not you are using Cloud Endpoints—you specify the interface ... prefix in HTTP path ('v2') than api...
Read more >
Customizing your gateway | gRPC-Gateway - GitHub Pages
Controlling path parameter unescaping​​ By default, gRPC-Gateway unescapes the entire URL path string attempting to route a request. This causes routing errors ...
Read more >
Language Guide (proto3) | Protocol Buffers - Google Developers
proto definition. An Any contains an arbitrary serialized message as bytes , along with a URL that acts as a globally unique identifier...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found