Skip to content

A sample gRPC application with docker and kubernetes configured for example purposes.

Notifications You must be signed in to change notification settings

anvilco/load-balance-grpc-k8s

Repository files navigation

Load Balancing gRPC in Kubernetes

This repository contains a configured gRPC sample application that can be run in Kubernetes to test proper load balancing. It will deploy client and server pods only accessible internally to a cluster. The client pod can run a script that will print the server host name.

This applicaiton is in support of our article on Load Balancing gRPC in Kubernetes with Istio. Refer to the article for a more detailed process on leveraging this application to improve load balancing in your kubernetes cluster.


Example repository maintained by Anvil

Horizontal Lockupblack Horizontal Lockup copywhite

Anvil provides easy APIs for all things paperwork.

  1. PDF filling API - fill out a PDF template with a web request and structured JSON data.
  2. PDF generation API - send markdown or HTML and Anvil will render it to a PDF.
  3. Etch E-sign with API - customizable, embeddable, e-signature platform with an API to control the signing process end-to-end.
  4. Anvil Workflows (w/ API) - Webforms + PDF + E-sign with a powerful no-code builder. Easily collect structured data, generate PDFs, and request signatures.

Learn more on our Anvil developer page.


Build

The image is prebuilt and availble. Just run docker pull ghcr.io/anvilco/load-balance-grpc-k8s:latest to pull locally. The Kubernetes manifest is already prepopulated with the public image. If you would like to modify the image or build yourself, you can edit the Dockerfile.

Deployment

All Kubernetes resources are stored in the k8s.yaml file. To deploy these resources into you cluster, you can follow a process like the following:

# Logging in to GKE (or your Kubernetes provider)
gcloud container clusters get-credentials cluster-1 --zone us-central1-c --project project-name

kubectl create namespace grpcdemo
kubectl config set-context --current --namespace=grpcdemo

kubectl apply -f ./k8s.yaml # Create the resources

Running Test Script

To execute the test script you need to ssh into the client pod.

kubectl get pods | grep greeter-client # The proxy pod
kubectl exec -it <pod name from above> -- bin/sh # Create a shell sessions to this pod

Once in the proxy pod, we can run our node script which will hit the gRPC servers and return a message along with the hostname of the server.

node greeter_client
# response…
##2 - Greeting: Hello from greeter-server-b8fb8c4b4-qjpjx, Anvil User!
#6 - Greeting: Hello from greeter-server-b8fb8c4b4-qjpjx, Anvil User!
#10 - Greeting: Hello from greeter-server-b8fb8c4b4-qjpjx, Anvil User!
#14 - Greeting: Hello from greeter-server-b8fb8c4b4-qjpjx, Anvil User!
#18 - Greeting: Hello from greeter-server-b8fb8c4b4-qjpjx, Anvil User!
#22 - Greeting: Hello from greeter-server-b8fb8c4b4-qjpjx, Anvil User!
#

Purpose

This test application provides insight into which pods are handling traffic. Looks through the responses and validate that there is an even split between servers handling requests.

Source

The basis for this example is pulled from the gRPC Node Example. More details and examples can be found in this repository.

About

A sample gRPC application with docker and kubernetes configured for example purposes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages