2020-04-23 17:12:30 -04:00
< p align = "center" >
< img src = "src/frontend/static/icons/Hipster_HeroLogoCyan.svg" width = "300" / >
< / p >
2018-07-02 10:24:11 -07:00
2020-04-23 17:12:30 -04:00
**Online Boutique** is a cloud-native microservices demo application.
Online Boutique consists of a 10-tier microservices application. The application is a
web-based e-commerce app where users can browse items,
2018-07-02 10:24:11 -07:00
add them to the cart, and purchase them.
2019-02-14 09:37:08 -08:00
**Google uses this application to demonstrate use of technologies like
2019-02-14 09:49:46 -08:00
Kubernetes/GKE, Istio, Stackdriver, gRPC and OpenCensus**. This application
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** .
2018-07-25 21:17:04 -07:00
2019-02-14 09:37:08 -08:00
If you’ re using this demo, please ** ★Star** this repository to show your interest!
> 👓**Note to Googlers:** Please fill out the form at
2019-02-20 14:34:12 -08:00
> [go/microservices-demo](http://go/microservices-demo) if you are using this
> application.
2019-01-14 14:42:13 -08:00
2020-04-24 11:43:31 -07:00
Looking for the old Hipster Shop frontend interface? Use the [manifests ](https://github.com/GoogleCloudPlatform/microservices-demo/tree/v0.1.5/kubernetes-manifests ) in release [v0.1.5 ](https://github.com/GoogleCloudPlatform/microservices-demo/releases/v0.1.5 ).
2020-04-23 17:12:30 -04:00
2018-08-13 11:23:42 -07:00
## Screenshots
2019-02-20 14:34:12 -08:00
| Home Page | Checkout Screen |
| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
2020-04-23 17:12:30 -04:00
| [](./docs/img/online-boutique-frontend-1.png) | [](./docs/img/online-boutique-frontend-2.png) |
2018-08-13 11:23:42 -07:00
## Service Architecture
2020-04-23 17:12:30 -04:00
**Online Boutique** is composed of many microservices written in different
2018-08-13 11:23:42 -07:00
languages that talk to each other over gRPC.
[](./docs/img/architecture-diagram.png)
2018-08-13 11:23:42 -07:00
Find **Protocol Buffers Descriptions** at the [`./pb` directory ](./pb ).
2019-02-20 14:34:12 -08:00
| Service | Language | Description |
| ---------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| [frontend ](./src/frontend ) | Go | Exposes an HTTP server to serve the website. Does not require signup/login and generates session IDs for all users automatically. |
2019-11-01 16:39:30 +01:00
| [cartservice ](./src/cartservice ) | C# | Stores the items in the user's shopping cart in Redis and retrieves it. |
2019-02-20 14:34:12 -08:00
| [productcatalogservice ](./src/productcatalogservice ) | Go | Provides the list of products from a JSON file and ability to search products and get individual products. |
| [currencyservice ](./src/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 ](./src/paymentservice ) | Node.js | Charges the given credit card info (mock) with the given amount and returns a transaction ID. |
| [shippingservice ](./src/shippingservice ) | Go | Gives shipping cost estimates based on the shopping cart. Ships items to the given address (mock) |
| [emailservice ](./src/emailservice ) | Python | Sends users an order confirmation email (mock). |
| [checkoutservice ](./src/checkoutservice ) | Go | Retrieves user cart, prepares order and orchestrates the payment, shipping and the email notification. |
| [recommendationservice ](./src/recommendationservice ) | Python | Recommends other products based on what's given in the cart. |
| [adservice ](./src/adservice ) | Java | Provides text ads based on given context words. |
| [loadgenerator ](./src/loadgenerator ) | Python/Locust | Continuously sends requests imitating realistic user shopping flows to the frontend. |
2018-08-13 11:23:42 -07:00
## Features
- **[Kubernetes ](https://kubernetes.io )/[GKE ](https://cloud.google.com/kubernetes-engine/ ):**
The app is designed to run on Kubernetes (both locally on "Docker for
Desktop", as well as on the cloud with GKE).
- **[gRPC ](https://grpc.io ):** Microservices use a high volume of gRPC calls to
communicate to each other.
- **[Istio ](https://istio.io ):** Application works on Istio service mesh.
- **[OpenCensus ](https://opencensus.io/ ) Tracing:** Most services are
instrumented using OpenCensus trace interceptors for gRPC/HTTP.
- **[Stackdriver APM ](https://cloud.google.com/stackdriver/ ):** 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.
2019-04-17 18:00:38 +02:00
- **[Skaffold ](https://skaffold.dev ):** Application
2018-08-13 11:23:42 -07:00
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 ](https://locust.io/ ) load generator.
## Installation
2020-02-15 02:47:18 +02:00
We offer the following installation methods:
2019-02-20 11:07:37 -08:00
2020-02-15 02:47:18 +02:00
1. **Running locally** (~20 minutes) You will build
2019-02-20 11:07:37 -08:00
and deploy microservices images to a single-node Kubernetes cluster running
2020-04-14 18:04:09 -07:00
on your development machine. There are three options to run a Kubernetes
2020-02-15 02:47:18 +02:00
cluster locally for this demo:
2020-04-14 18:04:09 -07:00
- [Minikube ](https://github.com/kubernetes/minikube ). Recommended for
2020-02-15 02:47:18 +02:00
Linux hosts (also supports Mac/Windows).
- [Docker for Desktop ](https://www.docker.com/products/docker-desktop ).
Recommended for Mac/Windows.
2020-06-07 12:17:50 -07:00
- [Kind ](https://kind.sigs.k8s.io ). Supports Mac/Windows/Linux.
2020-02-15 02:47:18 +02:00
2020-09-22 13:33:43 -07:00
1. **Running on Google Kubernetes Engine (GKE)** (~30 minutes) You will build,
2019-02-20 11:07:37 -08:00
upload and deploy the container images to a Kubernetes cluster on Google
Cloud.
2020-02-15 02:47:18 +02:00
1. **Using pre-built container images:** (~10 minutes, you will still need to
2019-02-20 11:07:37 -08:00
follow one of the steps above up until `skaffold run` command). With this
option, you will use pre-built container images that are available publicly,
instead of building them yourself, which takes a long time).
2020-06-02 14:26:53 -04:00
### Prerequisites
2018-07-02 11:03:55 -07:00
- kubectl (can be installed via `gcloud components install kubectl` )
2020-02-15 02:47:18 +02:00
- Local Kubernetes cluster deployment tool:
- [Minikube (recommended for
2020-04-14 18:04:09 -07:00
Linux)](https://kubernetes.io/docs/setup/minikube/)
- [Docker for Desktop (recommended for Mac/Windows) ](https://www.docker.com/products/docker-desktop )
- It provides Kubernetes support as [noted
here](https://docs.docker.com/docker-for-mac/kubernetes/)
- [Kind ](https://github.com/kubernetes-sigs/kind )
2020-06-02 14:26:53 -04:00
- [skaffold ]( https://skaffold.dev/docs/install/ ) ([ensure version ≥v1.10 ](https://github.com/GoogleContainerTools/skaffold/releases ))
- Enable GCP APIs for Cloud Monitoring, Tracing, Debugger:
```
gcloud services enable monitoring.googleapis.com \
cloudtrace.googleapis.com \
clouddebugger.googleapis.com
```
### Option 1: Running locally
> 💡 Recommended if you're planning to develop the application or giving it a
> try on your local cluster.
2018-07-10 19:47:24 -07:00
2020-06-02 14:26:53 -04:00
1. Launch a local Kubernetes cluster with one of the following tools:
2020-02-15 02:47:18 +02:00
2020-04-14 18:04:09 -07:00
- To launch **Minikube** (tested with Ubuntu Linux). Please, ensure that the
2020-02-15 02:47:18 +02:00
local Kubernetes cluster has at least:
- 4 CPU's
- 4.0 GiB memory
2020-06-01 13:06:07 -03:00
- 32 GB disk space
2019-02-20 14:34:12 -08:00
2020-04-14 18:04:09 -07:00
```shell
2020-06-01 13:06:07 -03:00
minikube start --cpus=4 --memory 4096 --disk-size 32g
2020-04-14 18:04:09 -07:00
```
2020-02-15 02:47:18 +02:00
2020-04-14 18:04:09 -07:00
- To launch **Docker for Desktop** (tested with Mac/Windows). Go to Preferences:
2020-02-15 02:47:18 +02:00
- choose “Enable Kubernetes”,
- set CPUs to at least 3, and Memory to at least 6.0 GiB
- on the "Disk" tab, set at least 32 GB disk space
2018-07-10 19:47:24 -07:00
2020-04-14 18:04:09 -07:00
- To launch a **Kind** cluster:
```shell
kind create cluster
```
2020-06-02 14:26:53 -04:00
2. Run `kubectl get nodes` to verify you're connected to “Kubernetes on Docker”.
2018-07-10 19:47:24 -07:00
2020-06-02 14:26:53 -04:00
3. Run `skaffold run` (first time will be slow, it can take ~20 minutes).
2018-08-09 14:40:43 -07:00
This will build and deploy the application. If you need to rebuild the images
2019-02-15 17:48:20 -05:00
automatically as you refactor the code, run `skaffold dev` command.
2018-07-10 19:47:24 -07:00
2020-06-02 14:26:53 -04:00
4. Run `kubectl get pods` to verify the Pods are ready and running.
2020-04-14 18:04:09 -07:00
2020-06-02 14:26:53 -04:00
5. Access the web frontend through your browser
2020-04-14 18:04:09 -07:00
- **Minikube** requires you to run a command to access the frontend service:
```shell
minikube service frontend-external
```
- **Docker For Desktop** should automatically provide the frontend at http://localhost:80
- **Kind** does not provision an IP address for the service.
You must run a port-forwarding process to access the frontend at http://localhost:8080:
```shell
kubectl port-forward deployment/frontend 8080:8080
```
2018-07-10 19:47:24 -07:00
2018-08-13 11:23:42 -07:00
### Option 2: Running on Google Kubernetes Engine (GKE)
2019-02-20 11:07:37 -08:00
> 💡 Recommended if you're using Google Cloud Platform and want to try it on
> a realistic cluster.
2018-07-10 19:47:24 -07:00
2019-02-20 14:34:12 -08:00
1. Create a Google Kubernetes Engine cluster and make sure `kubectl` is pointing
to the cluster.
2018-07-02 11:03:55 -07:00
2019-02-20 14:34:12 -08:00
```sh
gcloud services enable container.googleapis.com
```
2018-07-02 10:24:11 -07:00
2019-02-20 14:34:12 -08:00
```sh
gcloud container clusters create demo --enable-autoupgrade \
--enable-autoscaling --min-nodes=3 --max-nodes=10 --num-nodes=5 --zone=us-central1-a
```
2018-08-16 12:49:17 -07:00
2019-02-20 14:34:12 -08:00
```
kubectl get nodes
```
2018-08-13 11:23:42 -07:00
2020-06-02 14:26:53 -04:00
2. Enable Google Container Registry (GCR) on your GCP project and configure the
2019-02-20 14:34:12 -08:00
`docker` CLI to authenticate to GCR:
2018-08-16 12:49:17 -07:00
2019-02-20 14:34:12 -08:00
```sh
gcloud services enable containerregistry.googleapis.com
```
2018-07-02 11:03:55 -07:00
2019-02-20 14:34:12 -08:00
```sh
gcloud auth configure-docker -q
```
2018-07-02 10:24:11 -07:00
2020-06-02 14:26:53 -04:00
3. In the root of this repository, run `skaffold run --default-repo=gcr.io/[PROJECT_ID]` ,
2019-02-20 14:34:12 -08:00
where [PROJECT_ID] is your GCP project ID.
2019-01-15 10:14:33 -08:00
2019-02-20 14:34:12 -08:00
This command:
2019-02-20 11:07:37 -08:00
2019-02-20 14:34:12 -08:00
- builds the container images
- pushes them to GCR
- applies the `./kubernetes-manifests` deploying the application to
Kubernetes.
2018-07-02 10:24:11 -07:00
2019-02-20 14:34:12 -08:00
**Troubleshooting:** If you get "No space left on device" error on Google
Cloud Shell, you can build the images on Google Cloud Build: [Enable the
Cloud Build
API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com),
then run `skaffold run -p gcb --default-repo=gcr.io/[PROJECT_ID]` instead.
2018-11-07 14:52:31 -08:00
2020-06-02 14:26:53 -04:00
4. Find the IP address of your application, then visit the application on your
2018-08-13 11:23:42 -07:00
browser to confirm installation.
2018-07-02 10:24:11 -07:00
kubectl get service frontend-external
2018-11-07 14:52:31 -08:00
**Troubleshooting:** A Kubernetes bug (will be fixed in 1.12) combined with
a Skaffold [bug ](https://github.com/GoogleContainerTools/skaffold/issues/887 )
causes load balancer to not to work even after getting an IP address. If you
are seeing this, run `kubectl get service frontend-external -o=yaml | kubectl apply -f-`
to trigger load balancer reconfiguration.
2019-02-20 11:07:37 -08:00
### Option 3: Using Pre-Built Container Images
2019-01-29 11:23:33 -08:00
2019-02-20 11:07:37 -08:00
> 💡 Recommended if you want to deploy the app faster in fewer steps to an
> existing cluster.
2019-01-29 11:23:33 -08:00
2019-02-20 11:07:37 -08:00
**NOTE:** If you need to create a Kubernetes cluster locally or on the cloud,
follow "Option 1" or "Option 2" until you reach the `skaffold run` step.
2019-01-29 11:23:33 -08:00
2019-02-20 11:07:37 -08:00
This option offers you pre-built public container images that are easy to deploy
by deploying the [release manifest ](./release ) directly to an existing cluster.
**Prerequisite**: a running Kubernetes cluster (either local or on cloud).
1. Clone this repository, and go to the repository directory
2019-02-22 09:55:40 -08:00
1. Run `kubectl apply -f ./release/kubernetes-manifests.yaml` to deploy the app.
2019-02-20 11:07:37 -08:00
1. Run `kubectl get pods` to see pods are in a Ready state.
1. Find the IP address of your application, then visit the application on your
2019-02-20 14:34:12 -08:00
browser to confirm installation.
2019-02-20 11:07:37 -08:00
2019-02-20 14:34:12 -08:00
```sh
kubectl get service/frontend-external
```
2019-01-29 11:23:33 -08:00
2020-06-02 14:26:53 -04:00
### Option 4: Deploying on a Istio-enabled GKE cluster
2018-07-07 17:14:52 -07:00
2020-06-02 14:26:53 -04:00
> **Note:** if you followed GKE deployment steps above, run `skaffold delete` first to delete what's deployed.
2018-07-07 17:14:52 -07:00
2019-02-20 11:07:37 -08:00
1. Create a GKE cluster (described in "Option 2").
2019-01-15 10:14:33 -08:00
2020-06-02 14:26:53 -04:00
2. Use the [Istio on GKE add-on ](https://cloud.google.com/istio/docs/istio-on-gke/installing )
2019-01-15 10:14:33 -08:00
to install Istio to your existing GKE cluster.
2018-07-07 17:14:52 -07:00
2019-02-20 14:34:12 -08:00
```sh
gcloud beta container clusters update demo \
--zone=us-central1-a \
--update-addons=Istio=ENABLED \
--istio-config=auth=MTLS_PERMISSIVE
```
2018-10-09 11:50:14 -07:00
2020-06-02 14:26:53 -04:00
3. (Optional) Enable Stackdriver Tracing/Logging with Istio Stackdriver Adapter
2019-01-15 10:14:33 -08:00
by [following this guide ](https://cloud.google.com/istio/docs/istio-on-gke/installing#enabling_tracing_and_logging ).
2020-06-02 14:26:53 -04:00
4. Install the automatic sidecar injection (annotate the `default` namespace
2018-07-07 17:14:52 -07:00
with the label):
2019-02-20 14:34:12 -08:00
```sh
kubectl label namespace default istio-injection=enabled
```
2018-07-07 17:14:52 -07:00
2020-06-02 14:26:53 -04:00
5. Apply the manifests in [`./istio-manifests` ](./istio-manifests ) directory.
2019-02-20 14:34:12 -08:00
(This is required only once.)
2018-07-25 21:17:04 -07:00
2019-02-20 14:34:12 -08:00
```sh
kubectl apply -f ./istio-manifests
```
2018-08-13 11:23:42 -07:00
2020-06-02 14:26:53 -04:00
6. In the root of this repository, run `skaffold run --default-repo=gcr.io/[PROJECT_ID]` ,
2020-04-08 16:28:28 -07:00
where [PROJECT_ID] is your GCP project ID.
This command:
- builds the container images
- pushes them to GCR
- applies the `./kubernetes-manifests` deploying the application to
Kubernetes.
**Troubleshooting:** If you get "No space left on device" error on Google
Cloud Shell, you can build the images on Google Cloud Build: [Enable the
Cloud Build
API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com),
then run `skaffold run -p gcb --default-repo=gcr.io/[PROJECT_ID]` instead.
2018-08-16 12:49:17 -07:00
2020-06-02 14:26:53 -04:00
7. Run `kubectl get pods` to see pods are in a healthy and ready state.
2018-07-25 21:17:04 -07:00
2020-06-02 14:26:53 -04:00
8. Find the IP address of your Istio gateway Ingress or Service, and visit the
2018-08-13 11:23:42 -07:00
application.
2019-02-20 14:34:12 -08:00
```sh
INGRESS_HOST="$(kubectl -n istio-system get service istio-ingressgateway \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}')"
echo "$INGRESS_HOST"
```
2018-08-16 12:49:17 -07:00
2019-02-20 14:34:12 -08:00
```sh
curl -v "http://$INGRESS_HOST"
```
2018-08-16 12:49:17 -07:00
2019-03-29 18:25:34 +02:00
### 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.
2020-04-23 17:12:30 -04:00
## Conferences featuring Online Boutique
2019-01-08 10:51:36 -08:00
2019-01-15 10:14:33 -08:00
- [Google Cloud Next'18 London – Keynote ](https://youtu.be/nIq2pkNcfEI?t=3071 )
showing Stackdriver Incident Response Management
2019-01-08 10:51:36 -08:00
- Google Cloud Next'18 SF
2019-02-20 14:34:12 -08:00
- [Day 1 Keynote ](https://youtu.be/vJ9OaAqfxo4?t=2416 ) showing GKE On-Prem
2019-01-15 10:14:33 -08:00
- [Day 3 – Keynote ](https://youtu.be/JQPOPV_VH5w?t=815 ) showing Stackdriver
APM (Tracing, Code Search, Profiler, Google Cloud Build)
2019-01-08 10:51:36 -08:00
- [Introduction to Service Management with Istio ](https://www.youtube.com/watch?v=wCJrdKdD6UM&feature=youtu.be&t=586 )
2019-05-27 00:35:56 +02:00
- [KubeCon EU 2019 - Reinventing Networking: A Deep Dive into Istio's Multicluster Gateways - Steve Dake, Independent ](https://youtu.be/-t2BfT59zJA?t=982 )
2019-01-08 10:51:36 -08:00
README.md: add GCP-runnable version from Github
Hi there,
I recently created the linked repo to implement a Github automated workflow deploying Online Boutique with some standard tools for such a service mesh: Istio, Kiali, Prometheus, Grafana, Jaeger, etc. so that people get right away a complete demo/testbed close to "real life".
As you'll see in stars and forks, it raises quite some interest. So, I thought that it would be worth adding to the implementation featuring Online Boutique. I will keep it up to date when new versions of Online Boutique and tools are published.
Please, feel free to amend my proposed text if you accept this PR.
Best regards,
Didier
2020-10-06 07:04:20 +02:00
## Implementations (forks) featuring Online Boutique
- [Microservices on cloud-based Kubernetes ](https://github.com/didier-durand/microservices-on-cloud-kubernetes )
is an automated Github CI/CD workflow that can be forked to get a ready-to-use version of Online BBoutique on GCP / GKE. It also implements Istio, Kiali, Grafana, Jaeger, Prometheus, etc. to provide a thorougly instrumented version of the application delivering very realistic demos.
2018-07-25 21:17:04 -07:00
---
2019-02-20 14:34:12 -08:00
This is not an official Google project.