Code Monkey home page Code Monkey logo

hipster-shop's Introduction

This is a Lightstep fork of https://github.com/GoogleCloudPlatform/microservices-demo

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!

👓Note to Googlers: Please fill out the form at go/microservices-demo if you are using this application.

Home Page Checkout Page
Screenshot of store homepage Screenshot of checkout screen

Service Architecture

Hipster Shop is composed of many microservices written in different languages that talk to each other over gRPC.

Architecture of microservices

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.

Features

  • 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.
  • OpenCensus Tracing: Most services are instrumented using OpenCensus trace interceptors for gRPC/HTTP.
  • Stackdriver APM: Many services are instrumented with Profiling, Tracing and Debugging. In addition to these, using Istio enables features like Request/Response Metrics and Context Graph out of the box. When it is running out of Google Cloud, this code path remains inactive.
  • 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.

Installation Options

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

Prerequisites

GKE Installation Only

  • 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.

Local Installation Only

Install one of the following two options to run a Kubernetes cluster locally for this demo:

All Installations

  • kubectl: Install using gcloud components install kubectl
  • Local Kubernetes cluster deployment tool:
  • 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.

GKE Installation

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.

  1. 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
  2. Enable Google Container Registry (GCR) on your GCP project

    gcloud services enable containerregistry.googleapis.com
  3. Make sure kubectl is pointing to the cluster

    kubectl get nodes
    

    If you kept the name demo for the clusters (from the example in Step 1), you should see something like this:
    Screenshot of node listing

  4. Configure the docker CLI to authenticate to GCR:

    gcloud auth configure-docker -q
  5. In the root of this repository, run make setup.
    When asked What kind of Kubernetes cluster are you using?, choose 1) Google Kubernetes Engine (GKE).

  6. Find the external IP address of your application:
    kubectl get service frontend-external

  7. In your browser, visit that IP address to confirm installation. You should see the home page where you can shop for donuts and coffee. Hipster Shop home page

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.

Local Installation

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:

💡 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.

  1. 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.

  2. Navigate the root directory of the Hipster Shop repo clone and run: make setup When asked What kind of Kubernetes cluster are you using?, choose 2) Docker for Desktop or 3) Minikube and follow the configuration instructions.

  3. Run kubectl get pods to verify the Pods are ready and running.

  4. In a browser, visit http://localhost:80. You should see the home page where you can shop for donuts and coffee. Hipster Shop home page

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.

(Optional) Deploying on an Istio-installed GKE Cluster

Note: If you followed GKE deployment steps above, run skaffold delete first to delete what's deployed.

  1. Create a GKE cluster (described in GKE Installation). Go through Steps 1-4 (do not deploy the app).

  2. 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
  3. (Optional) Enable Stackdriver Tracing/Logging with Istio Stackdriver Adapter by following this guide.

  4. Install the automatic sidecar injection (annotate the default namespace with the label):

    kubectl label namespace default istio-injection=enabled
  5. Apply the manifests in ./istio-manifests directory. (This is required only once.)

    kubectl apply -f ./istio-manifests
  6. Deploy the application with skaffold run --default-repo=gcr.io/[PROJECT_ID].

  7. Run kubectl get pods to see pods are in a healthy and ready state.

  8. 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"
  9. In a browser, navigate to the app's IP address. You should see the home page where you can shop for donuts and coffee. Hipster Shop home page

See Telemetry Data in LightStep

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. Hipster home page

Check these out for more info on using LightStep:

Cleanup

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.

Conferences Featuring Hipster Shop


This is not an official Google project.

hipster-shop's People

Contributors

ahmetb avatar bcronin avatar benpbrown avatar mikegoldsmith avatar daniel-sanche avatar askmeegs avatar rghetia avatar mtwo avatar jkwlui avatar orthros avatar sebright avatar dependabot[bot] avatar heinencreative avatar davidstanke avatar jba avatar michaelawyu avatar ymotongpoo avatar robswhitmore avatar ocervell avatar kalyanac avatar idvoretskyi avatar rakyll avatar howardjohn avatar jsirianni avatar mdelio avatar mehdime avatar mshahat avatar oussemos avatar caulagi avatar riccardomc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.