-
Notifications
You must be signed in to change notification settings - Fork 4k
examples: Add XDS client example #6631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| gRPC XDS Example | ||
| ================ | ||
|
|
||
| The XDS example is a Hello World client capable of being configured with the | ||
| XDS management protocol. Out-of-the-box it behaves the same as hello world | ||
| client. | ||
|
|
||
| __XDS support is incomplete and experimental, with limited compatibility. It | ||
| will be very hard to produce a working enviornment just by this example. Please | ||
| refer to documentation specific for your XDS management server and | ||
| environment.__ | ||
|
|
||
| The example requires grpc-xds, but grpc-xds is not currently being published. | ||
| You will thus need to build it yourself. This should guide you, but if you | ||
| encounter issues please consult [COMPILING.md](../../COMPILING.md). | ||
|
|
||
| ### Build the example | ||
|
|
||
| 1. The server does not use XDS, so recent releases work fine. Building using | ||
| recent releases is much easier, so check out the most recent release tag: | ||
| ``` | ||
| $ git checkout v1.27.0 | ||
| ``` | ||
|
|
||
| 2. Build the hello-world example server or the hostname example server. See | ||
| [the examples README](../README.md) or the | ||
| [hostname example README](../example-hostname/README.md). | ||
|
|
||
| 3. Since XDS is still developing rapidly, XDS-using code should be built from | ||
| master: | ||
| ``` | ||
| $ git checkout master | ||
| ``` | ||
|
|
||
| 4. Building protoc-gen-grpc-java (the protoc plugin) requires a bit of work and | ||
| isn't necessary. So change the hello-world example to use the last released | ||
| version of the plugin. In `grpc-java/examples/build.gradle`, change: | ||
| ``` | ||
| grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" } | ||
| ``` | ||
| To: | ||
| ``` | ||
| grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.27.0" } | ||
| ``` | ||
|
|
||
|
|
||
| 5. Build this client. From the `grpc-java/examples/examples-xds` directory: | ||
| ``` | ||
| $ ../gradlew -PskipCodegen=true -PskipAndroid=true --include-build ../.. installDist | ||
| ``` | ||
|
|
||
| This creates the script `build/install/example-xds/bin/xds-hello-world-client` | ||
| that runs the example. | ||
|
|
||
| To start the server, run: | ||
|
|
||
| ``` | ||
| $ ../build/install/hostname/bin/hello-world-server | ||
| $ # or | ||
| $ ../example-hostname/build/install/hostname/bin/hostname-server | ||
| ``` | ||
|
|
||
| And in a different terminal window run this client: | ||
|
|
||
| ``` | ||
| $ ./build/install/example-xds/bin/xds-hello-world-client | ||
| ``` | ||
|
|
||
| However, that didn't use XDS! To use XDS we assume you have deployed the server | ||
| in your deployment environment and know its name. You need to set the | ||
| `GRPC_XDS_BOOTSTRAP` environment variable to point to a gRPC XDS bootstrap | ||
|
ejona86 marked this conversation as resolved.
|
||
| file (see [gRFC A27](https://github.com/grpc/proposal/pull/170) for the | ||
| bootstrap format). Then use the `xds-experimental:` target scheme during | ||
| channel creation. | ||
|
|
||
| ``` | ||
| $ export GRPC_XDS_BOOTSTRAP=/path/to/bootstrap.json | ||
| $ ./build/install/example-xds/bin/xds-hello-world-client "XDS world" xds-experimental:///yourServersName | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| plugins { | ||
| id 'application' // Provide convenience executables for trying out the examples. | ||
| id 'java' | ||
| } | ||
|
|
||
| repositories { | ||
| maven { // The google mirror is less flaky than mavenCentral() | ||
| url "https://maven-central.storage-download.googleapis.com/repos/central/data/" } | ||
| mavenCentral() | ||
| mavenLocal() | ||
| } | ||
|
|
||
| sourceCompatibility = 1.7 | ||
| targetCompatibility = 1.7 | ||
|
|
||
| // IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you | ||
| // are looking at a tagged version of the example and not "master"! | ||
|
|
||
| // Feel free to delete the comment at the next line. It is just for safely | ||
| // updating the version in our release process. | ||
| def grpcVersion = '1.28.0-SNAPSHOT' // CURRENT_GRPC_VERSION | ||
|
|
||
| dependencies { | ||
| // This example's client is the same as the helloworld client. We depend on the helloworld | ||
| // client's code here | ||
| implementation ':examples' | ||
| // The only change necessary is an extra runtime dependency on io.grpc:grpc-xds | ||
| runtimeOnly "io.grpc:grpc-xds:${grpcVersion}" | ||
| } | ||
|
|
||
| startScripts.enabled = false | ||
|
|
||
| task helloWorldClient(type: CreateStartScripts) { | ||
| mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient' | ||
| applicationName = 'xds-hello-world-client' | ||
| outputDir = new File(project.buildDir, 'tmp') | ||
| classpath = startScripts.classpath | ||
| } | ||
|
|
||
| applicationDistribution.into('bin') { | ||
| from(helloWorldClient) | ||
| fileMode = 0755 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| rootProject.name = 'example-xds' | ||
|
|
||
| includeBuild '..' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This number and below will be changed after every release. Add a line of instruction at https://github.com/grpc/grpc-java/pull/6631/files#diff-60cd2f42437b5cb3c2c09391a6f4c54aR125 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at the history of https://github.com/grpc/grpc-java/commits/master/documentation/android-channel-builder.md, we miss a commit "Update README etc to reference 1.27.0", but RELEASING.md doesn't document to add this commit in the master branch, while similar commits were added for the past releases. I'm confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I'm concerned, I'm okay if we don't update this. Two reasons: 1) it'll work fine, no big deal. 2) grpc-xds should be published the next release or the release after, so it will only be "wrong" for a maximum of one release. Once grpc-xds is published this will be rewritten to look like the other examples and just say "use the latest tag"