No description
Find a file
Ahmet Alp Balkan 2cbe4b6f01
Merge pull request #22 from rghetia/ads_proto
Add proto for Ads Service.
2018-08-16 09:21:15 -07:00
img img: make the screenshot sizes equal 2018-08-14 12:00:20 -07:00
istio-manifests Add more license headers 2018-07-25 21:25:27 -07:00
kubernetes-manifests Change gcr projectID in images 2018-08-04 11:23:35 -07:00
pb Add proto for Ads Service. 2018-08-16 09:11:26 -07:00
src go: use dep in builds, remove relative imports 2018-08-04 11:21:03 -07:00
tests/cartservice Add more license headers 2018-07-25 21:25:27 -07:00
.gitignore rm .vscode/ directory 2018-07-30 19:11:53 -07:00
CONTRIBUTING.md add LICENSE, CONTRIBUTING.md 2018-07-25 21:17:04 -07:00
LICENSE add LICENSE, CONTRIBUTING.md 2018-07-25 21:17:04 -07:00
README.md README: add screenshots, diagrams, features list 2018-08-13 11:28:15 -07:00
skaffold.yaml Change gcr projectID in images 2018-08-04 11:23:35 -07:00

Hipster Shop: Cloud-Native Microservices Demo Application

This project contains a 10-tier microservices 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 Kubernetes, GKE, Istio, Stackdriver, gRPC and similar cloud-native technologies nowadays.

Screenshots

Home Page Checkout Screen
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 shipping 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 (hypothetically😇) 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 (hypothetically😇)
emailservice Python Sends users an order confirmation email (hypothetically😇).
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.
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

Note: that the first build can take up to 20-30 minutes. Consequent builds will be faster.

Option 1: Running locally with “Docker for Desktop”

💡 Recommended if you're planning to develop the application.

  1. Install tools to run a Kubernetes cluster locally:

    • kubectl (can be installed via gcloud components install kubectl)
    • Docker for Desktop (Mac/Windows): It provides Kubernetes support as noted here.
    • skaffold
  2. Launch “Docker for Desktop”. Go to Preferences and choose “Enable Kubernetes”.

  3. Run kubectl get nodes to verify you're connected to “Kubernetes on Docker”.

  4. Run skaffold run (first time will be slow, it can take ~20-30 minutes). This will build and deploy the application. If you need to rebuild the images automatically as you refactor he code, run skaffold dev command.

  5. Run kubectl get pods to verify the Pods are ready and running. The application frontend should be available at http://localhost:80 on your machine.

Option 2: Running on Google Kubernetes Engine (GKE)

💡 Recommended for demos and making it available publicly.

  1. Install tools specified in the previous section (Docker, kubectl, skaffold)

  2. Create a Google Kubernetes Engine cluster and make sure kubectl is pointing to the cluster.

  3. Enable Google Container Registry (GCR) on your GCP project:

    gcloud services enable containerregistry.googleapis.com
    
  4. Configure docker to authenticate to GCR:

    gcloud auth configure-docker -q
    
  5. Edit skaffold.yaml, prepend your GCR registry host (gcr.io/YOUR_PROJECT/) to all imageName: fields (or update the existing project name).

  6. Edit the Deployment manifests at kubernetes-manifests directory and update the image fields to match the changes you made in the previous step.

  7. Run skaffold run. This builds the container images, pushes them to GCR, and deploys the application to Kubernetes.

  8. Find the IP address of your application then visit the application on your browser to confirm installation.

    kubectl get service frontend-external
    

(Optional) Deploying on a Istio-installed cluster

If you followed steps above, run skaffold delete to delete what's deployed.

  1. Create a GKE cluster.

  2. Install Istio without mutual TLS option. (Istio mTLS is not yet supported on this demo.)

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

    kubectl label namespace default istio-injection=enabled
    
  4. Deploy the application with skaffold run.

  5. Apply the manifests in ./istio-manifests directory.

    kubectl apply -f ./istio-manifests
    

    This is required only once.

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

  7. Find the IP address of your istio gateway Ingress or Service, and visit the application.


This is not an official Google project.