This repo contains sample code intended to be used for debugging and testing Gloo's Proxy.
The present code creates a KNative Service which exposes both HTTP and gRPC endpoints (with the help of cmux
).
addin
: A Microsoft Word Add-In intended to test gRPC-Web integration. (It's still a WIP)api/proto/
: Contains the proto definitionsclient-go/
: Contains a deployable gRPC clientgen/api/proto
:protoc-grpc-web
generated artifactsgloo/
: Contains the virtual services for deployment onto K8shelm/
: The Helm Charts that deploy the services as K8sDeployment
scompanion
: The playground companion add (MS Word Add-in to test gRPC-Web request)gloo-playground
: The playground serverplayground-cli
: The gRPC client for the playground
knative/
: Contains the KnativeService
Specservice.yaml
to deploy onto K8slibs
: Contains extensions/helper librarieskncloudevents
: A library that implements CNCF CloudEvents spec
src/
: Contains the code that is executed on the server containertooling/
:bazel/
: Contains the bazel dependencies and configurationsdocker/
: Contains the files required to build the sandbox Docker images. It also MUST contain you Docker Hub credentials if you intend to push images to your repominikube/
: Contains the scripts to setup and prepare a Minikube VM for development/testing purposes
playground.tf
: The Terraform deployment for the services via the Helm Chart (WARNING: The Terraform Helm provider does not yet fully support Helm 3)
In order to deploy the service into K8s execute the following command:
In order to deploy the service into K8s as a Knative Service
execute the following command:
kubectl apply -f knative/service.yaml
In order to deploy the service into K8s as a K8s Deployment
+ Service
execute there are two options available:
- Helm3
- Terraform
To use Helm directly:
helm install NAME helm/COMPONENT -f helm/COMPONENT/values.yaml --namespace default
If instead you want to use Terraform, then, from the root of the project simply init Terraform and apply:
terraform init
terraform apply (OPTIONALLY: -auto-approve)
Once the service is deployed, use glooctl
to get the name of the Upstream
associated with the Knative Service on your cluster and lookup the Upstream
on port 80 (HTTP to gRPC conversion) which should be something like NAMESPACE-COMPONENT_NAME-PORT
glooctl get upstreams
Now you can deploy the VirtualService
replacing the .spec.VirtualHost.routes.matcher.routeAction.single.upstream.name
with the Upstream
name you got on the previous step
Alternatively, you can define the Upstream
spec and name and use a predefined name (the one assigned to the Upstream
)
kubectl apply -f glooctl/virtualservice-$(VERSION).yaml
Verify the VirtualService
was properly created and is in Accepted
state
glooctl get virtualservices
If you use Visual Studio Code and the REST Client Extension, then you can use the rest-client.http
file to execute the requests to the service, on both gRPC and HTTP endpoints
For your convenience, there is a Makefile
available that provides a sandboxed build environment (Docker container) complete with Bazel and Gazelle, that is capable of building the required binaries and Docker images to test and deploy the services into a K8s cluster.
In order to be able to use make
you will have to create a Makefile.conf
file. Use the provided Makefile.conf.sample
to get you started. Once done, you can executing make
commands.
To setup the build environment just run:
make setup
To use the build environment use
make work
Bazel is the build system/platform used to build libraries, binaries, container images and packaging everything for deployment. The provided sandbox already has bazel installed so you can just start using it.
On the sandbox project root directory (/workspace
) execute the following command:
bazel build //:mux_function
NOTE: In order to be able to push images, there must exist a
config.json
file in thetooling/docker
directory with your Docker credentials. Use thetooling/docker/registry.config.json.sample
as a starting point to create your own credentials file.
To use Bazel to build and push a Docker image execute this command:
bazel run //:mux_image_push --define DOCKER_REGISTRY_IMAGE_NAME=$DOCKER_REGISTRY_IMAGE_NAME