Skip to content

Commit

Permalink
fix(grpc-xds): Use single xDS resource snapshot
Browse files Browse the repository at this point in the history
This version updates the control plane implementations to use a single
xDS resource snapshot for all nodes, instead of separate snapshots for
each node.

This commit also includes the following fixes and changes:

- Fix sending `xds:///` requests from the bastion troubleshooting pod.
  This is fixed by the use of a single xDS resource snapshot.
- Handle missing zone and node name in EndpointSlice
  (`control-plane-go`).
- Remove hardcoded server listener address and port. xDS-enabled
  gRPC servers can now use any address and port. New addresses and
  ports are captured on LDS stream creation.
- Use inline RouteConfiguration for server Listener instead of RDS in
  `control-plane-go`. This is a workaround for
  grpc/grpc-go#6683
- Enabled additional experimental gRPC xDS flags via envvars.
- Added make targets for mixing Go and Java control plane and greeter.
- Added steps for running kind on ChromeOS.
- Updated dependencies.
  • Loading branch information
halvards committed Oct 30, 2023
1 parent 59ed5f1 commit 499cb0f
Show file tree
Hide file tree
Showing 40 changed files with 1,333 additions and 372 deletions.
40 changes: 38 additions & 2 deletions grpc-xds-workshop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ tail-greeter-intermediary: check-kubectl
tail-greeter-leaf: check-kubectl
kubectl logs --all-containers --follow --namespace=xds deployment/greeter-leaf

# xds-status-intermediary shows the current xDS resources ACKed by greeter-intermediary
.PHONY: xds-status-intermediary
xds-status-intermediary: check-grpcdebug
grpcdebug localhost:50055 xds status

# xds-status-leaf shows the current xDS resources ACKed by greeter-leaf
.PHONY: xds-status-leaf
xds-status-leaf: check-grpcdebug
grpcdebug localhost:50057 xds status

# xds-config-intermediary dumps the current xDS configuration of greeter-intermediary
.PHONY: xds-config-intermediary
xds-config-intermediary: check-grpcdebug check-yq
grpcdebug localhost:50055 xds config | yq --input-format=json --prettyPrint

# xds-config-leaf dumps the current xDS configuration of greeter-leaf
.PHONY: xds-config-leaf
xds-config-leaf: check-grpcdebug check-yq
grpcdebug localhost:50057 xds config | yq --input-format=json --prettyPrint

# run-bastion deploys a bastion Pod with troubleshooting tools.
.PHONY: run-bastion
run-bastion: check-skaffold
Expand All @@ -86,12 +106,14 @@ troubleshoot: check-kubectl
# delete-control-plane deletes the Services and Deployments for control-plane-[go|java].
.PHONY: delete-control-plane
delete-control-plane:
kubectl delete --ignore-not-found --namespace=xds {deployment,service}/control-plane
kubectl delete --ignore-not-found --namespace=xds deployment control-plane
kubectl delete --ignore-not-found --namespace=xds service control-plane

# delete-greeter deletes the Services and Deployments for greeter-[intermediary|leaf].
.PHONY: delete-greeter
delete-greeter:
kubectl delete --ignore-not-found --namespace=xds {deployment,service}/greeter-{intermediary,leaf}
kubectl delete --ignore-not-found --namespace=xds deployment greeter-intermediary greeter-leaf
kubectl delete --ignore-not-found --namespace=xds service greeter-intermediary greeter-leaf

# delete deletes the Services and Deployments for control-plane and greeter-[intermediary|leaf],
# but leaves the bastion Pod running.
Expand All @@ -112,6 +134,13 @@ check-go:
exit 1; \
fi

.PHONY: check-grpcdebug
check-grpcdebug:
@if ! which grpcdebug > /dev/null; then \
echo "error: grpcdebug is not installed: https://github.com/grpc-ecosystem/grpcdebug#installation" >&2; \
exit 1; \
fi

.PHONY: check-grpcurl
check-grpcurl:
@if ! which grpcurl > /dev/null; then \
Expand Down Expand Up @@ -146,3 +175,10 @@ check-skaffold: check-kubectl check-kustomize
echo "error: skaffold is not installed: https://skaffold.dev/docs/install/" >&2; \
exit 1; \
fi

.PHONY: check-yq
check-yq:
@if ! which yq > /dev/null; then \
echo "error: yq is not installed: https://github.com/mikefarah/yq#install" >&2; \
exit 1; \
fi
21 changes: 15 additions & 6 deletions grpc-xds-workshop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ control planes for gRPC services running on Kubernetes.

The goal of the control plane implementations is to provide a practical
understanding of xDS, beyond the API specifications and the
[pithy](https://github.com/grpc/grpc-go/tree/v1.58.0/examples/features/xds)
[examples](https://github.com/grpc/grpc-java/tree/v1.58.0/examples/example-xds).
[pithy](https://github.com/grpc/grpc-go/tree/v1.59.0/examples/features/xds)
[examples](https://github.com/grpc/grpc-java/tree/v1.59.0/examples/example-xds).

This directory also contains accompanying sample applications implemented in
Go and Java. The sample applications implement the
[`helloworld.Greeter`](https://github.com/grpc/grpc-go/blob/v1.58.0/examples/helloworld/helloworld/helloworld.proto)
[`helloworld.Greeter`](https://github.com/grpc/grpc-go/blob/v1.59.0/examples/helloworld/helloworld/helloworld.proto)
gRPC service.

The code in this repository in not recommended for production deployments, and
Expand Down Expand Up @@ -89,6 +89,15 @@ Follow the steps in the documents
[Verify local development setup using Java](docs/verify-local-setup-java.md)
to ensure that your cluster and the prerequisite tools are set up correctly.

## Local cluster setup

If you use a kind Kubernetes cluster,
[create a multi-node cluster](docs/kind.md) with fake
[zone labels (`topology.kubernetes.io/zone`)](https://kubernetes.io/docs/reference/labels-annotations-taints/#topologykubernetesiozone).

The multi-node configuration and the zone labels enable you to simulate a
Kubernetes cluster with nodes across multiple cloud provider zones.

## Remote cluster and image registry setup

If you use a remote Kubernetes cluster and container image registry, e.g.,
Expand Down Expand Up @@ -199,8 +208,8 @@ make dev-java

## Remote debugging

Set up remote debugging by exposing and port-forwarding to the delve (for Go)
or the JDWP agent (for Java):
Set up remote debugging by exposing and port-forwarding to delve (for Go) or
the JDWP agent (for Java):

Using Go:

Expand All @@ -223,7 +232,7 @@ make debug-java
make run-bastion
```

This takes a few minutes, as the pod installs a number of tools.
This takes a few minutes, as an init container installs a number of tools.

2. Open an interactive shell in the pod's container:
Expand Down
14 changes: 12 additions & 2 deletions grpc-xds-workshop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ plugins {
id 'idea'

id 'com.dorongold.task-tree' version '2.1.1' apply false
id 'com.github.ben-manes.versions' version '0.44.0' apply false
id 'com.github.spotbugs' version '5.0.13' apply false
id 'com.github.ben-manes.versions' version '0.49.0' apply false
id 'com.github.spotbugs' version '5.2.1' apply false
}

repositories {
Expand All @@ -44,6 +44,13 @@ idea {
}
}

// https://github.com/ben-manes/gradle-versions-plugin#rejectversionsif-and-componentselection
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}

subprojects {
buildscript {
repositories {
Expand Down Expand Up @@ -87,5 +94,8 @@ subprojects {
checkConstraints = true
checkForGradleUpdate = true
gradleReleaseChannel = 'current'
rejectVersionIf {
isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)
}
}
}
3 changes: 2 additions & 1 deletion grpc-xds-workshop/control-plane-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ tail:
# delete the xds control plane Deployment and Service resources from the k8s cluster.
.PHONY: delete
delete:
kubectl delete --ignore-not-found --namespace=xds {deployment,service}/control-plane
kubectl delete --ignore-not-found --namespace=xds deployment control-plane
kubectl delete --ignore-not-found --namespace=xds service control-plane

.PHONY: build
build:
Expand Down
4 changes: 2 additions & 2 deletions grpc-xds-workshop/control-plane-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Kubernetes, implemented in Go.

The goal of this implementation is to provide a practical understanding of xDS,
beyond the API specifications and the
[pithy examples](https://github.com/grpc/grpc-go/tree/v1.57.0/examples/features/xds).
[pithy examples](https://github.com/grpc/grpc-go/tree/v1.59.0/examples/features/xds).

This sample implementation is not recommended for production deployments, and
there are no plans to make it production-ready. Instead, we recommend
[Traffic Director](https://cloud.google.com/traffic-director/docs) from Google Cloud.

## References

- [gRPC xDS example](https://github.com/grpc/grpc-go/tree/v1.57.0/examples/features/xds)
- [gRPC xDS example](https://github.com/grpc/grpc-go/tree/v1.59.0/examples/features/xds)
- [Example xDS Server](https://github.com/envoyproxy/go-control-plane/tree/v0.11.1/internal/example)
- [Example Envoy control plane](https://github.com/envoyproxy/go-control-plane/tree/v0.11.1/examples/dyplomat)

Expand Down
32 changes: 16 additions & 16 deletions grpc-xds-workshop/control-plane-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ go 1.20

require (
github.com/envoyproxy/go-control-plane v0.11.1
github.com/go-logr/logr v1.2.4
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0
google.golang.org/grpc v1.58.0
github.com/go-logr/logr v1.3.0
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.28.1
k8s.io/apimachinery v0.28.1
k8s.io/client-go v0.28.1
k8s.io/api v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
k8s.io/klog/v2 v2.100.1
)

require (
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 // indirect
github.com/cncf/xds/go v0.0.0-20231016030527-8bd2eac9fb4a // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
Expand All @@ -41,9 +41,9 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -53,20 +53,20 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/kube-openapi v0.0.0-20230905202853-d090da108d2f // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 499cb0f

Please sign in to comment.