smazzone / microservices-demo-multiarch

Sample cloud-native application with 10 microservices showcasing K8S, Istio, gRPC, etc. Fully deployable on a Raspberry Pi 4 cluster. This has been forked from https://github.com/GoogleCloudPlatform/microservices-demo and updated in many different files to make it work on a Raspberry Pi4 cluster running 1 master and 3 worker nodes. It works on Mac M1 as well.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swagstore

Release 0.5.0 - multiarch (amd and arm support)

Dec 2022

Swagstore is a fork of Google Online Boutique which in turn is a cloud-first microservices demo application.

The app consists of an 11-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. Swagstore is a slightly modified version from the original Online Boutique. In fact, items on the Swagstore are actually Datadog swags. It is a ficticious ecommerce swag store, don't expect to receive swags 😀

Google uses this application to demonstrate use of technologies like Kubernetes/GKE, Istio, Stackdriver, and gRPC. This application works on any Kubernetes cluster, as well as Google Kubernetes Engine. It’s easy to deploy with little to no configuration.

At Datadog we use the app to experiment with APM, Tracing Libraries, Admission Controller and auto injection. It is perfect as a playground if you want to play and instrument the microservices written in multiple languages.

If you’re using this demo, please ★Star this repository to show your interest!

Screenshots

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

Architecture

Swagstore is composed of 11 microservices written in different languages that talk to each other over gRPC. See the Development Principles doc for more information.

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.
  • Cloud Operations (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.
  • 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.

Deploy Swagstore Demo app

Do you have a running K8s cluster? If not either use Docker Desktop or Minikube or Kind or your K8s cluster or your GKE

Don't forget to install Git, Skaffold 2.0+ and kubectl. Check the prerequisites section above.

Launch a local Kubernetes cluster with one of the following tools:

Option 1 - Local Cluster

  1. Launch a local Kubernetes cluster with one of the following tools:

    • To launch Minikube (tested with Ubuntu Linux). Please, ensure that the local Kubernetes cluster has at least:

      • 4 CPUs
      • 4.0 GiB memory
      • 32 GB disk space
      minikube start --cpus=4 --memory 4096 --disk-size 32g
    • To launch Docker for Desktop (tested with Mac/Windows). Go to Preferences:

      • 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
    • To launch a Kind cluster:

      kind create cluster
  2. Run kubectl get nodes to verify you're connected to the respective control plane.

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

    change the platform accordingly

    change the default-repo to point to your personal hub account if you want to use your own images or you can use mine

    if you are on Mac M1 or M2 or you are on arm use the --platform accordingly

    skaffold run --default-repo docker.io/smazzone --platform=linux/arm64

    if you are on a PC or an Intel-based Mac or you are on amd use the --platform accordingly

    skaffold run --default-repo docker.io/smazzone --platform=linux/amd64

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

  5. Docker Desktop should automatically provide the frontend at http://localhost:80

  6. Minikube requires you to run a command to access the frontend service: minikube service frontend-external

  7. 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: kubectl port-forward deployment/frontend 8080:8080 to forward a port to the frontend service.

  8. Navigate to either http://localhost:80 or http://localhost:8080 to access the web frontend.

Cleanup

If you've deployed the application with skaffold run command, you can run skaffold delete to clean up the deployed resources.

Option 2: Google Kubernetes Engine (GKE)

💡 Recommended if you're using Google Cloud Platform and want to try it on a realistic cluster. Note: If your cluster has Workload Identity enabled, see these instructions

  1. Create a Google Kubernetes Engine cluster and make sure kubectl is pointing to the 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
    kubectl get nodes
    
  2. 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
  3. 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.

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

    kubectl get service frontend-external
    

Local Development

If you would like to contribute features or fixes to this app, see the Development Guide on how to build this demo locally.

Demos featuring Online Boutique


This is not an official Google project.

About

Sample cloud-native application with 10 microservices showcasing K8S, Istio, gRPC, etc. Fully deployable on a Raspberry Pi 4 cluster. This has been forked from https://github.com/GoogleCloudPlatform/microservices-demo and updated in many different files to make it work on a Raspberry Pi4 cluster running 1 master and 3 worker nodes. It works on Mac M1 as well.

License:Apache License 2.0


Languages

Language:Python 29.3%Language:Go 27.3%Language:HTML 8.6%Language:C# 7.2%Language:Dockerfile 7.1%Language:Shell 4.8%Language:JavaScript 4.3%Language:CSS 4.3%Language:HCL 3.7%Language:Java 3.4%