This application is based on this repository by Google™
To view the final presentation, click here.
The application is currently deployed here.
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, add them to the cart, and purchase them.
Google uses Online Boutique to demonstrate use of technologies like Kubernetes/GKE, Istio, Stackdriver, gRPC and OpenCensus. This repository contains a revamped version of Online Boutique, that can be run on Google Kubernetes Engine. It's easy to deploy and tear down. Complete step-by-step to deploy and tear down this application can be found on Installation section below.
Home Page | Checkout Screen |
---|---|
Online Boutique 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. Sign in (with Google) is not required to browse items and add to cart, but required when checkout. |
cartservice | C# | Stores the items in the user's shopping cart in Redis and retrieves it. |
productcatalogservice | Go | Provides the list of products from Cloud Firestore and ability to get the details of 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. Logs order history to Cloud SQL for further processing with Cloud Dataflow, BigQuery, and Data Studio. |
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 Google Kubernetes Engine.
- gRPC: Microservices use a high volume of gRPC calls to communicate to each other.
- 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. Uses Faker to help generate random email and street addresses.
Additional Features (compared to the official Online Boutique)
- Firebase Authentication: The application provides user authentication by Sign in with Google Account and autofill the user's email when checkout.
- Firestore & Cloud Storage: The application fetches its products from Firestore, and the product images can be stored on Cloud Storage.
- Cloud SQL: The application uses Cloud SQL to store Order information.
- Terraform: The application use Terraform to automate creation and teardown of various GCP resources such as GKE cluster, Cloud Storage, and Cloud SQL instance.
- Faker & Google Geocoding API: The application generates random users and addresses for load testing, then converts the addresses to geolocation coordinates.
- Dataflow: The application uses Dataflow, a fully managed data processing service, to load data from Cloud SQL (transactional database) to BigQuery (analytical database).
- BigQuery: The application uses BigQuery, a serverless data warehouse, to enable scalable data analysis.
- Data Studio: The application uses Data Studio to quickly visualize the data that have been processed in BigQuery.
We offer the following installation method:
Running on Google Kubernetes Engine (GKE)” (~30 minutes)
- You will build, upload and deploy the container images to a Kubernetes cluster on Google Cloud.
- kubectl (can be installed via
gcloud components install kubectl
) - skaffold (ensure version ≥v1.10)
- Enable GCP APIs for Cloud Monitoring, Tracing, Debugger:
gcloud services enable monitoring.googleapis.com \ cloudtrace.googleapis.com \ clouddebugger.googleapis.com
💡 You can try it on a realistic cluster using Google Cloud Platform.
-
Enable Google Kubernetes Engine API
gcloud services enable container.googleapis.com
-
Run
terraform apply
in the directory/terraform
. Enter your GCP Project ID and thenyes
.It will create GCP resources used in the application:
Resources Explanation GKE cluster For deployment Cloud Storage Buckets Product images, Firestore backup Cloud Storage Objects Product images Cloud SQL Instance Store Order information Service Accounts For Firestore, Cloud SQL -
Connect
kubectl
with clusterdemo
gcloud container clusters get-credentials demo --zone asia-east1-a --project <GCP_project_ID>
-
Configuring Firebase Authentication
- Create a new Firebase Project on Firebase Console and connect it with your GCP Project.
- Go to Project Settings on the Firebase Console to get your
firebaseConfig
. - Update
firebaseConfig
here accordingly (necessary fields only).
-
Configuring Cloud Firestore
- On the GCP Console, go to Firestore and select Native Mode.
- Copy firestore-backup to the Cloud Storage Bucket created by Terraform
gsutil cp -r firestore-backup/content gs://<Project ID>-firestore-backup
- Import Firestore backup from the Cloud Storage Bucket
gcloud firestore import gs://<Project ID>-firestore-backup/content/
- On the Firestore interface, update the value of
picture
field on each products because your product image links are different. Change them tohttps://storage.googleapis.com/<Project ID>-product-image/xxx.jpg
. - Update
projectID
for the Firestore client here. - Create a new JSON key of the service account
firestore-sa
created by Terraform, and save it on directory/src/productcatalogservice
. - Update your JSON key file name on .gitignore, Dockerfile, and code.
-
Configuring Cloud SQL
- Terraform has created Cloud SQL instance and service account needed by the application.
- Create Kubernetes secret
kubectl create secret generic order-secret \ --from-literal=db_user=root \ --from-literal=db_password=<GCP_project_ID> \ --from-literal=db_name=order
- Update project ID for Kubernetes service account annotation on yaml.
- Update Cloud SQL instance connection name on yaml and code.
-
Enable Google Container Registry (GCR) on your GCP project and configure the
docker
CLI to authenticate to GCR:gcloud services enable containerregistry.googleapis.com
gcloud auth configure-docker -q
-
You can turn off order load generator by setting
tasks > checkout
here to 0. Else, the generated addresses are processed with Geocoding API. Don't forget to enable it. -
In the root of this repository, run
skaffold run --default-repo=gcr.io/[PROJECT_ID]
, 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, then run
skaffold run -p gcb --default-repo=gcr.io/[PROJECT_ID]
instead. -
Find the IP address of your application, then visit the application on your browser to confirm installation.
kubectl get service frontend-external
Troubleshooting: A Kubernetes bug (will be fixed in 1.12) combined with a Skaffold bug 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. -
Authorize the domain for Firebase Authentication
- Go to Authentication section on the Firebase Console and enable Sign-in method: Google.
- Add the IP address of your deployed application to the Authorized domains.
You can run skaffold delete
to clean up the deployed resources.
- 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.