This is a Lightstep fork of https://github.com/GoogleCloudPlatform/microservices-demo
🔎 Looking for the latest examples of using OpenTelemetry instrumentation with microservices? Check out opentelemetry-demo-webstore, a new community-driven project.
- Hipster Shop: Cloud-Native Observability Demo Application
The application is a web-based e-commerce app called Hipster Shop where users can browse items, add them to the cart, and purchase them. Google uses this application to demonstrate use of technologies like Kubernetes/GKE, Istio, Stackdriver, gRPC and OpenCensus.
This fork of the repository demonstrate how to instrument for distributed tracing and monitoring using multiple tracing libraries, including OpenTelemetry, OpenTracing, and tracers from LightStep, Zipkin, and Jaeger. Use the app to learn and experiment with distributed system telemetry and then run LightStep to see your telemetry data in action.
💡 Don't have a LightStep account? Sign up for LightStep Developer!
This project contains a 10-tier microservices application, where services are built using different languages and different tracing libraries. It works on any Kubernetes cluster (such as a local one), as well as Google Kubernetes Engine. It’s easy to deploy with little to no configuration.
If you’re using this demo, please ★Star this repository to show your interest!
Home Page | Checkout Page |
---|---|
Hipster Shop is composed of many microservices written in different languages that talk to each other over gRPC.
Find Protocol Buffers Descriptions at the ./pb
directory.
Service | Language | Description |
---|---|---|
frontend | Go | Exposes an HTTP server to serve the website. Does not require signup/login and generates session IDs for all users automatically. |
cartservice | C# | Stores the items in the user's shopping cart in Redis and retrieves it. |
productcatalogservice | Go | Provides the list of products from a JSON file and ability to search products and get individual products. |
currencyservice | Node.js | Converts one money amount to another currency. Uses real values fetched from European Central Bank. It's the highest QPS service. |
paymentservice | Node.js | Charges the given credit card info (mock) with the given amount and returns a transaction ID. |
shippingservice | Go | Gives shipping cost estimates based on the shopping cart. Ships items to the given address (mock) |
emailservice | Python | Sends users an order confirmation email (mock). |
checkoutservice | Go | Retrieves user cart, prepares order and orchestrates the payment, shipping and the email notification. |
recommendationservice | Python | Recommends other products based on what's given in the cart. |
adservice | Java | Provides text ads based on given context words. |
loadgenerator | Python/Locust | Continuously sends requests imitating realistic user shopping flows to the frontend. |
- Kubernetes/GKE: The app is designed to run on Kubernetes (both locally on "Docker for Desktop", as well as on the cloud with GKE).
- gRPC: Microservices use a high volume of gRPC calls to communicate to each other.
- Istio: Application works on Istio service mesh.
- OpenTelemetry Tracing: Most services are instrumented using OpenTelemetry trace interceptors for gRPC/HTTP.
- Skaffold: Application is deployed to Kubernetes with a single command using Skaffold.
- Synthetic Load Generation: The application demo comes with a background job that creates realistic usage patterns on the website using Locust load generator.
You can install the Hipster-Shop into these environments:
- Google Kubernetes Engine (GKE): Install the app to a similar environment that you'll deploy your production system to.
- Locally: Deploy to a single-node Kubernetes cluster running on your own development machine, using either Minikube (recommended for Linux) or Docker for Desktop (recommended for Mac/Windows). Both installations take between 20-30 minutes
-
Google Cloud Platform account: Visit console.cloud.google.com to set up your account.
Create and activate your project, and make sure billing is activated for your account. -
Set the project ID as an environment variable
export GCP_PROJECT_ID=<your-project-ID>
-
Google Cloud Console (command line tool): Visit cloud.google.com/pubsub/docs/quickstart-cli for instructions.
-
Run
gcloud init
to configure Google Cloud (GC). Follow the console instructions. If you've already created a project in GC, be sure to select that project.
Install one of the following two options to run a Kubernetes cluster locally for this demo:
- Minikube. Recommended for the Linux hosts (also supports Mac/Windows).
- Docker for Desktop. Recommended for Mac/Windows.
- kubectl: Install using
gcloud components install kubectl
- Local Kubernetes cluster deployment tool:
- Minikube (recommended for Linux).
- Docker for Desktop (recommended for Mac/Windows): It provides Kubernetes support as noted here.
- skaffold: Ensure the version is ≥ v0.20)
- LightStep account and project: You can sign up for LightStep Developer if you don't already have an account. A new LightStep account includes two projects---dev and production. You can use one of these or create a new one.
- LightStep access token: This token is needed to determine the LightStep project that this app should send it's telemetry to. You can find it in LightStep's project settings.
Set the token as an environment variable:
export LIGHTSTEP_ACCESS_TOKEN= - A clone of this repo: You won't be able to create a branch or push changes to this repo, so if you want to be able to check in any changes, create a fork instead.
Time to install: About 30 minutes
You will build, upload and deploy the container images to a Kubernetes cluster on Google Cloud.
💡 Recommended if you're using Google Cloud Platform and want to try it on a realistic cluster.
💡 Be sure to follow all prerequisites before starting installation.
-
From the cloned repo directory, create a Google Kubernetes Engine cluster .
gcloud services enable container.googleapis.com
gcloud container clusters create demo --enable-autoupgrade \ --enable-autoscaling --min-nodes=3 --max-nodes=10 --num-nodes=5 --zone=us-central1-a
-
Enable Google Container Registry (GCR) on your GCP project
gcloud services enable containerregistry.googleapis.com
-
Make sure
kubectl
is pointing to the clusterkubectl get nodes
If you kept the name
demo
for the clusters (from the example in Step 1), you should see something like this:
-
Configure the
docker
CLI to authenticate to GCR:gcloud auth configure-docker -q
-
In the root of this repository, run
$ LIGHTSTEP_ACCESS_TOKEN=[your token] make setup
.
When askedWhat kind of Kubernetes cluster are you using?
, choose1) Google Kubernetes Engine (GKE)
. -
Find the external IP address of your application:
kubectl get service frontend-external
-
In your browser, visit that IP address to confirm installation. You should see the home page where you can shop for donuts and coffee.
Now go to See Telemetry Data in LightStep to see how data from the app is visualized in LightStep and learn how you can quickly resolve issues.
Time to install: About 20 minutes
You will build and deploy microservices images to a single-node Kubernetes cluster running on your development machine.
Use one of the following for you cluster:
- Minikube (recommended for Linux).
- Docker for Desktop (recommended for Mac/Windows): It provides Kubernetes support as noted here.
💡 Recommended if you're planning to develop the application or you want to try on your local cluster.
💡 Be sure to follow all prerequisites before starting installation.
-
Run
kubectl get nodes
to verify you're connected to “Kubernetes on Docker”.💡If not connected, run
kubectl config use-context docker-desktop
to connect Kubernetes to Docker. -
Navigate the root directory of the Hipster Shop repo clone and run:
$ LIGHTSTEP_ACCESS_TOKEN=[your token] make setup
When askedWhat kind of Kubernetes cluster are you using?
, choose2) Docker for Desktop
or3) Minikube
and follow the configuration instructions. -
Run
kubectl get pods
to verify the Pods are ready and running. -
In a browser, visit http://localhost:80. You should see the home page where you can shop for donuts and coffee.
Now go to See Telemetry Data in LightStep to see how data from the app is visualized in LightStep and learn how you can quickly resolve issues.
Note: If you followed GKE deployment steps above, run
skaffold delete
first to delete what's deployed.
-
Create a GKE cluster (described in GKE Installation). Go through Steps 1-4 (do not deploy the app).
-
Use Istio on GKE add-on to install Istio to your existing GKE cluster.
gcloud beta container clusters update demo \ --zone=us-central1-a \ --update-addons=Istio=ENABLED \ --istio-config=auth=MTLS_PERMISSIVE
-
(Optional) Enable Stackdriver Tracing/Logging with Istio Stackdriver Adapter by following this guide.
-
Install the automatic sidecar injection (annotate the
default
namespace with the label):kubectl label namespace default istio-injection=enabled
-
Apply the manifests in
./istio-manifests
directory. (This is required only once.)kubectl apply -f ./istio-manifests
-
Deploy the application with
skaffold run --default-repo=gcr.io/[PROJECT_ID]
. -
Run
kubectl get pods
to see pods are in a healthy and ready state. -
Find the IP address of your Istio gateway Ingress or Service.
INGRESS_HOST="$(kubectl -n istio-system get service istio-ingressgateway \ -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" echo "$INGRESS_HOST"
curl -v "http://$INGRESS_HOST"
-
In a browser, navigate to the app's IP address. You should see the home page where you can shop for donuts and coffee.
- An EKS cluster with a managed node group in AWS
- Istio installed on the cluster, including istio-ingressgateway, with istio enabled set to true
- AWS cli installed, and
~/.aws/credentials
with an AWS account that has permissions to interact with the EKS cluster and ECR - ECR repos created for holding each of the hipster shop services
- Skaffold installed (
brew install skaffold
)
- Switch to the EKS cluster's kube context.
aws eks --region us-east-1 update-kubeconfig --name <cluster name>
- Install the automatic sidecar injection (annotate the
default
namespace with the label):
kubectl label namespace default istio-injection=enabled
- Create a Lightstep access token k8s secret:
kubectl create secret generic lightstep-credentials --from-literal=accessToken=<access token>
- Apply the istio manifests that come with hipster-shop, cd to the repository where you have hipster-shop cloned and run:
kubectl apply -f ./istio-manifests
- Authenticate with ECR so that skaffold is able to push to the repositories (there must be one per service):
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <ecr repository root path>
Example repository root path: <aws account id>.dkr.ecr.us-east-1.amazonaws.com/hipster-shop
, where a child path would be <aws account id>.dkr.ecr.us-east-1.amazonaws.com/hipster-shop/currencyservice
6. Deploy with skaffold (this command takes long to run and may timeout, doesn't necessarily mean it didn't work, the deployments just take a while sometimes):
skaffold run --default-repo=<ecr repository root path>
- Get the URL to navigate to your deployed hipster-shop.
kubectl -n istio-ingress get service istio-ingress -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'
Browse and purchase a few items (a dummy credit card and service are configured to allow purchasing), then go to the LightStep app and open the Explorer page for your project.
You should see the Latency Histogram, which shows the distribution of spans over latency periods. Spans are shown in latency buckets - longer blue lines mean there are more spans in that latency bucket. Lines towards the left have lower latency and towards the right, higher latency.
Check these out for more info on using LightStep:
- LightStep Product Overview(video): Take a tour through LightStep
- Play in the LightStep Sandbox: Work directly in LightStep to resolve a performance regression, debug and iOS error, and monitor a deploy.
- Learning Paths: Run through tutorials to learn how to use LightStep resolve issues in deep systems.
- LightStep Blog: Read and learn the latest from LightStep.
- LightStep Learning Portal: Browse through the LightStep product docs.
If you've deployed the application with skaffold run
command, you can run
skaffold delete
to clean up the deployed resources.
If you've deployed the application with kubectl apply -f [...]
, you can
run kubectl delete -f [...]
with the same argument to clean up the deployed
resources.
If you've deployed the application with make setup
, then you can clean up the deployed resources with make clean
- Google Cloud Next'18 London – Keynote showing Stackdriver Incident Response Management
- Google Cloud Next'18 SF
- Day 1 Keynote showing GKE On-Prem
- Day 3 – Keynote showing Stackdriver APM (Tracing, Code Search, Profiler, Google Cloud Build)
- Introduction to Service Management with Istio
- KubeCon EU 2019 - Reinventing Networking: A Deep Dive into Istio's Multicluster Gateways - Steve Dake, Independent
This is not an official Google project.