Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ install:
- pushd examples/example-hostname && mvn verify && popd
- pushd examples/example-tls && ../gradlew clean build && popd
- pushd examples/example-kotlin && ../gradlew build && popd
- pushd examples/example-xds && ../gradlew build && popd

before_script:
- test -z "$(git status --porcelain)" || (git status && echo Error Working directory is not clean. Forget to commit generated files? && false)
Expand Down
1 change: 1 addition & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ $ VERSION_FILES=(
examples/example-kotlin/android/helloworld/app/build.gradle
examples/example-tls/build.gradle
examples/example-tls/pom.xml
examples/example-xds/build.gradle
)
```

Expand Down
3 changes: 3 additions & 0 deletions buildscripts/kokoro/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ if [[ -z "${SKIP_TESTS:-}" ]]; then
pushd examples/example-tls
mvn clean verify --batch-mode
popd
pushd examples/example-xds
../gradlew build $GRADLE_FLAGS
popd
# TODO(zpencer): also build the GAE examples
fi

Expand Down
79 changes: 79 additions & 0 deletions examples/example-xds/README.md
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
Copy link
Copy Markdown
Contributor

@dapengzhang0 dapengzhang0 Jan 29, 2020

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 ?

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Member Author

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"

```

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
Comment thread
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
```
43 changes: 43 additions & 0 deletions examples/example-xds/build.gradle
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
}
3 changes: 3 additions & 0 deletions examples/example-xds/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rootProject.name = 'example-xds'

includeBuild '..'