Skip to content

DataDog/tsre-microservices

 
 

Repository files navigation

Swagstore

DPN Tears of SRE Microservices - Swagstore

The Swagstore app consists of an 12-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.

It is a fictitious e-commerce swag store, don't expect to receive swags 😀

Screenshots

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

Architecture

The application is running on a single node kubernetes cluster using minikube

Architecture of microservices

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 Java Charges the given credit card info (mock) with the given amount and returns a transaction ID.
paymentdbservice MariaDB Store all charges and payment information according to 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.

How to Use

Datadog Agent

The Datadog Cluster Agent configuration is located in ctf/datadog-values.yaml.

Note: If you are running the Datadog Cluster Agent locally (e.g., via Docker) or on Google Cloud, ensure that certain settings, such as datadog.networkMonitoring.enabled, are disabled.

Running the Application

All service configuration files are available in the kubernetes-manifests directory.

If using the TSRE Terraform Script, the application will be started automatically using start.sh.

For TSRE challenges requiring updates to the paymentservice and frontend codebase, use the update.sh script to reload the changes.

If you are running TSRE Microservices locally or not using the TSRE Terraform Script, run the following commands from the tsre-microservices repository to start the services:

# Deploy services with pre-built images from AWS Public Registry:
kubectl apply -f kubernetes-manifests/adservice.yaml
kubectl apply -f kubernetes-manifests/cartservice.yaml
kubectl apply -f kubernetes-manifests/checkoutservice.yaml
kubectl apply -f kubernetes-manifests/currencyservice.yaml
kubectl apply -f kubernetes-manifests/emailservice.yaml
kubectl apply -f kubernetes-manifests/loadgenerator.yaml
kubectl apply -f kubernetes-manifests/paymentdbservice.yaml
kubectl apply -f kubernetes-manifests/productcatalogservice.yaml
kubectl apply -f kubernetes-manifests/recommendationservice.yaml
kubectl apply -f kubernetes-manifests/redis.yaml
kubectl apply -f kubernetes-manifests/shippingservice.yaml

# Deploy paymentservice and frontend (services not pre-built):
skaffold build
skaffold run

Rebuilding the Services

To rebuild services after making code changes in the src directory:

  1. Ensure that your IAM user in the DPN Network IAM has read/write access to the Public ECR Registry (e.g., AWS user).

  2. Authenticate Docker with your IAM user on your local machine (replace <Username> and <Password>):

aws ecr-public get-login-password --region us-east-1 | docker login --username <Username> --password-stdin <Password>
  1. Rebuild the images (replace <tag-name> as needed). Run these commands from the tsre-microservices directory:
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/adservice:<tag-name> --push src/adservice/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/cartservice:<tag-name> --push src/cartservice/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/checkoutservice:<tag-name> --push src/checkoutservice/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/currencyservice:<tag-name> --push src/currencyservice/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/emailservice:<tag-name> --push src/emailservice/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/loadgenerator:<tag-name> --push src/loadgenerator/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/paymentdbservice:<tag-name> --push src/paymentdbservice/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/productcatalogservice:<tag-name> --push src/productcatalogservice/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/recommendationservice:<tag-name> --push src/recommendationservice/
docker buildx build --platform linux/amd64,linux/arm64 -t public.ecr.aws/v6x4t1k2/shippingservice:<tag-name> --push src/shippingservice/
  1. Update the spec.template.spec.containers.image in the respective tsre-microservices/ctf/<servicename>.yaml file with the appropriate tag.

Misc

Swagstore is a heavily modified version from the original Online Boutique. In fact, items on the Swagstore are actually Datadog swags.

About

TSRE - Swagstore Shop application with 12 microservices

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 31.1%
  • Go 21.9%
  • Shell 10.9%
  • Java 9.0%
  • HTML 8.5%
  • Dockerfile 7.4%
  • Other 11.2%