Skip to content

Commit fb76af5

Browse files
pradeepbblPradeep Mishratoddbaertbeeme1mr
authored
docs: added gRPC custom name resolver proposal (#1414)
## This PR Added initial gRPC custom name resolver draft proposal - new proposal doc to support gRPC over proxy ### Related Issues TBD --------- Signed-off-by: Pradeep Mishra <[email protected]> Signed-off-by: Pradeep <[email protected]> Signed-off-by: Pradeep Mishra <[email protected]> Signed-off-by: Pradeep Mishra <[email protected]> Co-authored-by: Pradeep Mishra <[email protected]> Co-authored-by: Todd Baert <[email protected]> Co-authored-by: Michael Beemer <[email protected]>
1 parent 85a3a6b commit fb76af5

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# gRPC Custom Name Resolver Proposal (DRAFT)
2+
3+
## Details
4+
5+
| | |
6+
|------------------------|------------------------------------|
7+
| **Feature Name** | gRPC custom name resolver |
8+
| **Type** | enhancement |
9+
| **Related components** | gRPC source resolution |
10+
11+
## Summary
12+
13+
gRPC by default supports DNS resolution which is currently being used e.g. "localhost:8013" in both
14+
[core](https://github.com/open-feature/flagd/blob/main/core/pkg/sync/grpc/grpc_sync.go#L72-L74) and
15+
providers e.g. [java](https://github.com/open-feature/java-sdk-contrib/blob/main/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/ChannelBuilder.java#L53-L55).
16+
This covers most deployments, but with increased adoption of microservice-architecture, service discovery,
17+
policy-enabled service meshes (e.g. istio, envoy, consul, etc) it's necessary to support custom routing and name resolution.
18+
19+
For such cases the gRPC core libraries support few alternative resolver* also expose the required interfaces to build custom implementations:
20+
21+
### Reference
22+
23+
* [Custom Name Resolution](https://grpc.io/docs/guides/custom-name-resolution/)
24+
* [Java Client](https://grpc.github.io/grpc-java/javadoc/io/grpc/ManagedChannelBuilder.html#forTarget(java.lang.String))
25+
* [Golang](https://pkg.go.dev/google.golang.org/grpc#NewClient)
26+
27+
**Note:** There is small variation in supported alternative resolver e.g. java support `zooKeeper`
28+
29+
## Motivation
30+
31+
The main motivation is to support complex deployments with a generic custom name resolver using the interface
32+
provided by gRPC core*.
33+
34+
**Note**: As of now only `java` and `golang` has the required interface to create custom resolver
35+
36+
## Detailed design
37+
38+
The idea is to
39+
40+
* allow a new config option to pass the [target](https://grpc.io/docs/guides/custom-name-resolution/#life-of-a-target-string) string
41+
* reduce need to create/override existing implementations to simplify use of name-resolver
42+
43+
### Target String Pattern*
44+
45+
Below is an example of a custom target string which will use envoy sidecar proxy for name resolution
46+
47+
```text
48+
envoy://localhost:9211/flagd-sync.service
49+
```
50+
51+
The custom name resolver provider in this case will use the endpoint name i.e. `flagd-sync.service` as [authority](https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/nameresolve/ExampleNameResolver.java#L55-L61)
52+
and connect to `localhost:9211`
53+
54+
```mermaid
55+
sequenceDiagram
56+
participant application
57+
participant flagd-provider
58+
participant proxy-sidecar-agent
59+
participant flagd-sync.service
60+
61+
application->>flagd-provider: Check the state of a feature flag
62+
flagd-provider-->>application: Get the feature flag from in-memory cache <br/> run the evaluation logic and return final state
63+
loop
64+
flagd-provider->>flagd-provider: in-memory cache
65+
end
66+
flagd-provider->>proxy-sidecar-agent: gRPC stream connection
67+
proxy-sidecar-agent-->>flagd-provider:
68+
Note right of flagd-provider: Instead host:port target string <br> "envoy://localhost:9211/flagd-sync.service" <br> will be used
69+
proxy-sidecar-agent->>flagd-sync.service: Apply required policy and route traffic <br> to backend nodes
70+
flagd-sync.service-->>proxy-sidecar-agent:
71+
Note right of proxy-sidecar-agent: Policy and route rules are applied based <br> on `authority` header used by the <br> gRPC client
72+
```
73+
74+
#### Drawbacks
75+
76+
* One of the big drawback was limited support of the language only `java` and `golang`
77+
* Will introduce inconsistent user experience
78+
* Will open the door for different use cases although this can be fixed by
79+
providing sdks similar to [custom connector](https://github.com/open-feature/java-sdk-contrib/tree/main/providers/flagd#custom-connector)
80+
* ...
81+
82+
## Alternatives
83+
84+
### Option-1
85+
86+
Allow users to override default `authority` header as shown above in `grpcurl`, the override option was
87+
already supported by all major languages*
88+
89+
* [Golang](https://pkg.go.dev/google.golang.org/grpc#WithAuthority)
90+
* [JAVA](https://grpc.github.io/grpc-java/javadoc/io/grpc/ForwardingChannelBuilder2.html#overrideAuthority(java.lang.String))
91+
* [Python](https://grpc.github.io/grpc/python/glossary.html#term-channel_arguments)
92+
93+
this option is simple and easy to implement, although it will not cover all the cases it will at least help with proxy
94+
setup where `host_header` was used to route traffic.
95+
96+
**Ref**:
97+
98+
Java PR: <https://github.com/open-feature/java-sdk-contrib/pull/949>
99+
100+
**Note**: JS, .NET, PHP still need to be explored if this options available
101+
102+
### Option-2
103+
104+
Only support the [xDS](https://grpc.io/docs/guides/custom-load-balancing/#service-mesh) protocol which already supported by gRPC core and doesn't require any custom
105+
name resolver we can simply use any `target` string with `xds://` scheme. The big benefit of this approach was
106+
it's going to be new stranded when it comes gRPC with service mesh and eliminate any custom implementation in `flagd`
107+
and the gRPC core team actively adding more features e.g. mTLS
108+
109+
For more details refer the below document
110+
111+
* [gRPC xDS Feature](https://grpc.github.io/grpc/core/md_doc_grpc_xds_features.html)
112+
* [gRPC xDS RFC](https://github.com/grpc/proposal/blob/master/A52-xds-custom-lb-policies.md)
113+
114+
### Option-3
115+
116+
TBD
117+
118+
## Unresolved questions
119+
120+
* What to do with un-supported languages
121+
* Coming up with generic name resolver which will cover most of the cases not just proxy
122+
* ....

0 commit comments

Comments
 (0)