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.

Alternative to GRPC_XDS_BOOSTRAP env variable

See original GitHub issue

Goal

I’m looking into creating a utility function that can dynamically create and assign the xDS bootstrap. This could be hooked into the application startup so that xDS can be configured across different environments (IDE, GCE, GKE) without the need of startup shell scripts etc.

While almost every programming language supports dynamically setting environment variables, Java does not. Would it be possible to have an alternative way in java to provide the location of the bootstrap file?

Possible solution

One possible solution that doesn’t break the existing API and gRPC spec would be to also try reading e.g. a java system property (System.getProperty(“grpc.xds.bootstrap”)😉 at https://github.com/grpc/grpc-java/blob/beb3232c0a6c2873292da7d24fb9f678a7f5a650/xds/src/main/java/io/grpc/xds/Bootstrapper.java#L57-L61 In the case that the GRPC_XDS_BOOSTRAP environment variable isn’t found.

Maybe something as simple as:

private static final String BOOTSTRAP_PATH_SYS_PROPERTY_VAR = "grpc.xds.bootstrap";
.
.
.
String filePath = Optional.ofNullable(System.getenv(BOOTSTRAP_PATH_SYS_ENV_VAR))
                          .orElse(System.getProperty(BOOTSTRAP_PATH_SYS_PROPERTY_VAR)); 

Alternatives

Alternative solutions would most likely require larger changes to the existing classes in order to pass the config down.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
srini100commented, Nov 10, 2020

I guess it would be even nicer to be able to provide the bootstrap config directly to gRPC without the need of a temporary json file, but that’s maybe stretching it a bit too far, since no other grpc implementation would have such a feature and it may require exposing some internals that might change later on.

We should consider this. Istio uses PROXY_CONFIG env variable for bootstrap config without using a file. It is good to have an option that doesn’t require a file to be mounted.

1reaction
erikjohcommented, Nov 9, 2020

As for the priority, my spontaneous thought is that the env variable should have higher prio so that all existing gRPC proxyless documentation still would apply without edge cases. I imagine that a developer might want to learn about proxyless gRPC and follow the official documentation. If the java property took precedence and they used a service framework that internally sets that property and creates the file then they might waste some thought cycles trying to figure out “why it didn’t work as they thought”. But if there are other scenarios that can motivate why the property should take precedence I think that’s fine as well since we could just ignore setting the property if the env variable is set 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set up service security with proxyless gRPC | Traffic Director
In a proxyless service mesh, a gRPC client uses the scheme xds: in the URI to ... Set your specific values to the...
Read more >
gRPC Hostname Example - Google Git
Point the GRPC_XDS_BOOTSTRAP environment variable at the bootstrap file: export GRPC_XDS_BOOTSTRAP=/etc/xds-bootstrap.json. Run the client:.
Read more >
gRPC Proxyless Service Mesh - Istio
Istio dynamically configures its Envoy sidecar proxies using a set of discovery APIs, collectively known as the xDS APIs.
Read more >
Envoy Proxy Configuration | Service Mesh | Consul
Envoy proxies require two types of configuration: an initial bootstrap ... The CONSUL_HTTP_TOKEN environment variable contains a Consul ACL token.
Read more >
Istio: pkg/bootstrap/config.go - Fossies
DiscoveryAddress, ":")[0] 79 80 xdsType := "GRPC" 81 if features. ... 141 142 // substituteValues substitutes variables known to the bootstrap like pod_ip....
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