From 72897e955ddb11558eef3c2790c985af2f42af49 Mon Sep 17 00:00:00 2001 From: Giselle van Dongen Date: Thu, 1 Feb 2024 11:54:49 +0100 Subject: [PATCH 1/2] Fix ecommerce example to work with new ports for runtime and service --- typescript/ecommerce-store/README.md | 9 +- .../deployment/docker/docker-compose-pg.yml | 9 +- .../deployment/docker/docker-compose.yml | 11 +- .../deployment/knative/README.md | 10 +- .../deployment/knative/deploy.yaml | 8 +- .../ecommerce-store/services/Dockerfile | 4 +- .../ecommerce-store/services/package.json | 6 +- typescript/package-lock.json | 289 ++++++++---------- 8 files changed, 156 insertions(+), 190 deletions(-) diff --git a/typescript/ecommerce-store/README.md b/typescript/ecommerce-store/README.md index 3a9b690f..4f9b4201 100644 --- a/typescript/ecommerce-store/README.md +++ b/typescript/ecommerce-store/README.md @@ -36,24 +36,19 @@ Restate is a system for easily building resilient applications using **distribut ## Deployment on Docker Compose -Build the Docker containers for the web app and services: - -```shell -docker build -t dev.local/shopping-cart/react-app:0.0.1 ./react-shopping-cart -docker build ./services/ -t dev.local/shopping-cart/services:0.0.1 -``` - You can store the products data in the Restate runtime or in a separate Postgres DB: 1. To store the products in Restate state, bring up the Docker Compose setup via: ```shell +docker compose -f deployment/docker/docker-compose.yml build --no-cache docker compose -f deployment/docker/docker-compose.yml up ``` 2. To store the products in a Postgres DB, bring up the Docker Compose setup via: ```shell +docker compose -f deployment/docker/docker-compose-pg.yml build --no-cache docker compose -f deployment/docker/docker-compose-pg.yml up ``` diff --git a/typescript/ecommerce-store/deployment/docker/docker-compose-pg.yml b/typescript/ecommerce-store/deployment/docker/docker-compose-pg.yml index df160b2b..379c2588 100644 --- a/typescript/ecommerce-store/deployment/docker/docker-compose-pg.yml +++ b/typescript/ecommerce-store/deployment/docker/docker-compose-pg.yml @@ -1,7 +1,8 @@ version: "3.3" services: services: - image: dev.local/shopping-cart/services:0.0.1 + build: + context: ../../services environment: - DATABASE_ENABLED=true - RESTATE_DEBUG_LOGGING=JOURNAL_VERBOSE @@ -22,6 +23,7 @@ services: ports: - "8080:8080" - "9070:9070" + - "9071:9071" environment: - RUST_LOG=info,restate=debug - RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://jaeger:4317 @@ -32,7 +34,7 @@ services: - runtime - services restart: "no" - entrypoint: ["sh", "-c", "sleep 5 && curl -X POST 'runtime:9070/deployments' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' || exit 1"] + entrypoint: ["sh", "-c", "sleep 5 && curl -X POST 'runtime:9070/deployments' -H 'content-type: application/json' -d '{\"uri\": \"http://services:9080\"}' || exit 1"] db: image: 'postgres:15.0-alpine' @@ -59,7 +61,8 @@ services: PGADMIN_LISTEN_PORT: 5050 react_app: - image: dev.local/shopping-cart/react-app:0.0.1 + build: + context: ../../react-shopping-cart depends_on: - runtimesetup ports: diff --git a/typescript/ecommerce-store/deployment/docker/docker-compose.yml b/typescript/ecommerce-store/deployment/docker/docker-compose.yml index de985f3c..6dfbdba0 100644 --- a/typescript/ecommerce-store/deployment/docker/docker-compose.yml +++ b/typescript/ecommerce-store/deployment/docker/docker-compose.yml @@ -1,7 +1,8 @@ version: "3.3" services: services: - image: dev.local/shopping-cart/services:0.0.1 + build: + context: ../../services environment: - RESTATE_DEBUG_LOGGING=JOURNAL_VERBOSE - DATABASE_ENABLED=false @@ -22,6 +23,7 @@ services: ports: - "8080:8080" - "9070:9070" + - "9071:9071" environment: - RUST_LOG=info,restate=debug - RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://jaeger:4317 @@ -36,12 +38,13 @@ services: - ../local/:/scripts - ../data/:/data entrypoint: ["sh", "-c", "sleep 5 && apk add --no-cache bash jq curl && - curl -X POST 'runtime:9070/deployments' -H 'content-type: application/json' -d '{\"uri\": \"http://services:8080\"}' && - sleep 3 && cd /scripts && chmod +x init_state.sh && ./init_state.sh runtime:9090 + curl -X POST 'runtime:9070/deployments' -H 'content-type: application/json' -d '{\"uri\": \"http://services:9080\"}' && + sleep 3 && cd /scripts && chmod +x init_state.sh && ./init_state.sh runtime:8080 || exit 1"] react_app: - image: dev.local/shopping-cart/react-app:0.0.1 + build: + context: ../../react-shopping-cart depends_on: - runtimesetup ports: diff --git a/typescript/ecommerce-store/deployment/knative/README.md b/typescript/ecommerce-store/deployment/knative/README.md index adc26de4..ff3ab1b2 100644 --- a/typescript/ecommerce-store/deployment/knative/README.md +++ b/typescript/ecommerce-store/deployment/knative/README.md @@ -33,7 +33,7 @@ kubectl create ns shopping-cart 4. Deploy application The `deploy.yaml` file lists the services that will be deployed on Kubernetes. -You can deploy them via: +From the root of the `ecommerce-store` example, you can deploy them via: ```shell kubectl apply -n shopping-cart -f deployment/knative/deploy.yaml @@ -50,13 +50,13 @@ You can visit the web app at http://localhost:3000 6. Forwards the ports of the Restate runtime: ```shell -kubectl port-forward -n shopping-cart svc/restate-runtime 8080:8080 9070:9070 +kubectl port-forward -n shopping-cart svc/restate-runtime 8080:8080 9070:9070 9071:9071 ``` 7. Execute the service discovery: ```shell -curl -X POST http://localhost:9070/endpoint/discover -H 'content-type: application/json' -d '{"uri": "http://services.shopping-cart.svc.cluster.local"}' +curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://services.shopping-cart.svc.cluster.local"}' ``` 8. Fill the state of the product service with a list of products: @@ -76,10 +76,10 @@ If you order some T-shirts in the UI, you will see services spin up. ## Deleting the application -In order to delete the deployed application run: +To delete the deployed application run: ```shell -kubectl delete -n shopping-cart -f deploy.yaml +kubectl delete -n shopping-cart -f deployment/knative/deploy.yaml ``` Then bring down the cluster via: diff --git a/typescript/ecommerce-store/deployment/knative/deploy.yaml b/typescript/ecommerce-store/deployment/knative/deploy.yaml index f9c9f46d..d1193485 100644 --- a/typescript/ecommerce-store/deployment/knative/deploy.yaml +++ b/typescript/ecommerce-store/deployment/knative/deploy.yaml @@ -23,6 +23,8 @@ spec: name: grpc - containerPort: 9070 name: meta + - containerPort: 9071 + name: admin --- apiVersion: v1 @@ -43,6 +45,10 @@ spec: port: 9070 protocol: TCP targetPort: 9070 + - name: admin + port: 9071 + protocol: TCP + targetPort: 9071 --- apiVersion: apps/v1 @@ -87,7 +93,7 @@ spec: imagePullPolicy: Never ports: - name: h2c - containerPort: 8080 + containerPort: 9080 env: - name: RESTATE_DEBUG_LOGGING value: JOURNAL_VERBOSE diff --git a/typescript/ecommerce-store/services/Dockerfile b/typescript/ecommerce-store/services/Dockerfile index 3d3417ec..df94c91f 100644 --- a/typescript/ecommerce-store/services/Dockerfile +++ b/typescript/ecommerce-store/services/Dockerfile @@ -16,7 +16,7 @@ RUN npm run build ENV NODE_ENV production -ENV PORT 8080 -EXPOSE 8080 +ENV PORT 9080 +EXPOSE 9080 USER node CMD ["dumb-init", "node", "./dist/app.js"] diff --git a/typescript/ecommerce-store/services/package.json b/typescript/ecommerce-store/services/package.json index 2d96b193..39819979 100644 --- a/typescript/ecommerce-store/services/package.json +++ b/typescript/ecommerce-store/services/package.json @@ -27,11 +27,13 @@ "pg": "^8.10.0", "pg-hstore": "^2.3.4", "sequelize": "^6.30.0", - "uuid": "^9.0.0" + "uuid": "^9.0.0", + "protobufjs": "^7.2.2", + "ts-proto": "^1.140.0" }, "devDependencies": { "@aws-sdk/client-rds-data": "^3.289.0", - "@bufbuild/buf": "^1.26.1", + "@bufbuild/buf": "1.26.1", "@types/node": "^18.14.2", "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^6.3.0", diff --git a/typescript/package-lock.json b/typescript/package-lock.json index e1b67688..692ba8c8 100644 --- a/typescript/package-lock.json +++ b/typescript/package-lock.json @@ -25,12 +25,14 @@ "long": "^5.2.1", "pg": "^8.10.0", "pg-hstore": "^2.3.4", + "protobufjs": "^7.2.2", "sequelize": "^6.30.0", + "ts-proto": "^1.140.0", "uuid": "^9.0.0" }, "devDependencies": { "@aws-sdk/client-rds-data": "^3.289.0", - "@bufbuild/buf": "^1.26.1", + "@bufbuild/buf": "1.26.1", "@types/node": "^18.14.2", "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^6.3.0", @@ -42,6 +44,125 @@ "typescript": "^5.1.6" } }, + "ecommerce-store/services/node_modules/@bufbuild/buf": { + "version": "1.26.1", + "resolved": "https://registry.npmjs.org/@bufbuild/buf/-/buf-1.26.1.tgz", + "integrity": "sha512-NyYx4T//3ndtFYV3BfqX9Xrm1NZEx3eChXniAKc/osCVViFooC5nuLQUbyqglMonH0w39RohiURMXN+e/oEB4g==", + "dev": true, + "hasInstallScript": true, + "bin": { + "buf": "bin/buf", + "protoc-gen-buf-breaking": "bin/protoc-gen-buf-breaking", + "protoc-gen-buf-lint": "bin/protoc-gen-buf-lint" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@bufbuild/buf-darwin-arm64": "1.26.1", + "@bufbuild/buf-darwin-x64": "1.26.1", + "@bufbuild/buf-linux-aarch64": "1.26.1", + "@bufbuild/buf-linux-x64": "1.26.1", + "@bufbuild/buf-win32-arm64": "1.26.1", + "@bufbuild/buf-win32-x64": "1.26.1" + } + }, + "ecommerce-store/services/node_modules/@bufbuild/buf-darwin-arm64": { + "version": "1.26.1", + "resolved": "https://registry.npmjs.org/@bufbuild/buf-darwin-arm64/-/buf-darwin-arm64-1.26.1.tgz", + "integrity": "sha512-nmyWiT/59RFja0ZuXFxjNGoAMDPTApU66CZUUevkFVWbNB9nzeQDjx2vsJyACY64k5fTgZiaelSiyppwObQknw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "ecommerce-store/services/node_modules/@bufbuild/buf-darwin-x64": { + "version": "1.26.1", + "resolved": "https://registry.npmjs.org/@bufbuild/buf-darwin-x64/-/buf-darwin-x64-1.26.1.tgz", + "integrity": "sha512-jl5WmUv30OW8JiRLid9+mVx1XVH0XttpUfkQfmqDFdUHGfdy4XWYK8kr84YyWu0SiMTIt1mPXkqG5UM3x+tdIQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "ecommerce-store/services/node_modules/@bufbuild/buf-linux-aarch64": { + "version": "1.26.1", + "resolved": "https://registry.npmjs.org/@bufbuild/buf-linux-aarch64/-/buf-linux-aarch64-1.26.1.tgz", + "integrity": "sha512-EedR2KDW/yDIxQKWuq1Y/g7IuwTgvelqylGVO7muMxt2JWShobyUaU6GIU8JB4yhIbqRQYCL2KqBsvDJbJtCUw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "ecommerce-store/services/node_modules/@bufbuild/buf-linux-x64": { + "version": "1.26.1", + "resolved": "https://registry.npmjs.org/@bufbuild/buf-linux-x64/-/buf-linux-x64-1.26.1.tgz", + "integrity": "sha512-5iFL+MmWqR4cBLVNpgsjRecdHgcTxFaIkVYlQV9q8acbaJn5rgOIjUr1tzcBao9YsL3rdBhHvKkgnQ9gi1IiTw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "ecommerce-store/services/node_modules/@bufbuild/buf-win32-arm64": { + "version": "1.26.1", + "resolved": "https://registry.npmjs.org/@bufbuild/buf-win32-arm64/-/buf-win32-arm64-1.26.1.tgz", + "integrity": "sha512-/ayymSD12gBetN98ErkH0CBGRLTmtYAp4fmbPuvq8zuJcL0eiAnK6d7ZFjTc+vDMuKY/aelQN7dj9WhzdYAQSQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "ecommerce-store/services/node_modules/@bufbuild/buf-win32-x64": { + "version": "1.26.1", + "resolved": "https://registry.npmjs.org/@bufbuild/buf-win32-x64/-/buf-win32-x64-1.26.1.tgz", + "integrity": "sha512-k9Dy3Z9P96wYR43lUhUo0jbjMSo001+MRBlsadEYiw85POqx6RWVaGyHLrxC2Ly7g+aGMisey050OjqfCWtKTA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "ecommerce-store/services/node_modules/@types/node": { "version": "18.17.7", "dev": true, @@ -57,6 +178,7 @@ "food-ordering/services": { "name": "@restatedev/example-food-ordering", "version": "0.0.1", + "extraneous": true, "license": "MIT", "dependencies": { "@restatedev/restate-sdk": "^0.7.0", @@ -1229,43 +1351,6 @@ "tslib": "^2.3.1" } }, - "node_modules/@bufbuild/buf": { - "version": "1.26.1", - "dev": true, - "hasInstallScript": true, - "license": "Apache-2.0", - "bin": { - "buf": "bin/buf", - "protoc-gen-buf-breaking": "bin/protoc-gen-buf-breaking", - "protoc-gen-buf-lint": "bin/protoc-gen-buf-lint" - }, - "engines": { - "node": ">=12" - }, - "optionalDependencies": { - "@bufbuild/buf-darwin-arm64": "1.26.1", - "@bufbuild/buf-darwin-x64": "1.26.1", - "@bufbuild/buf-linux-aarch64": "1.26.1", - "@bufbuild/buf-linux-x64": "1.26.1", - "@bufbuild/buf-win32-arm64": "1.26.1", - "@bufbuild/buf-win32-x64": "1.26.1" - } - }, - "node_modules/@bufbuild/buf-darwin-arm64": { - "version": "1.26.1", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "dev": true, @@ -1829,10 +1914,6 @@ "resolved": "ecommerce-store/services", "link": true }, - "node_modules/@restatedev/example-food-ordering": { - "resolved": "food-ordering/services", - "link": true - }, "node_modules/@restatedev/example-hello-world-lambda": { "resolved": "hello-world-lambda", "link": true @@ -2853,11 +2934,6 @@ "node": ">=8" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" - }, "node_modules/aws-cdk": { "version": "2.121.1", "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.121.1.tgz", @@ -2913,13 +2989,11 @@ }, "node_modules/aws-cdk-lib/node_modules/@balena/dockerignore": { "version": "1.0.2", - "extraneous": true, "inBundle": true, "license": "Apache-2.0" }, "node_modules/aws-cdk-lib/node_modules/ajv": { "version": "8.12.0", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -2935,7 +3009,6 @@ }, "node_modules/aws-cdk-lib/node_modules/ansi-regex": { "version": "5.0.1", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -2944,7 +3017,6 @@ }, "node_modules/aws-cdk-lib/node_modules/ansi-styles": { "version": "4.3.0", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -2959,7 +3031,6 @@ }, "node_modules/aws-cdk-lib/node_modules/astral-regex": { "version": "2.0.0", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -2968,13 +3039,11 @@ }, "node_modules/aws-cdk-lib/node_modules/balanced-match": { "version": "1.0.2", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/aws-cdk-lib/node_modules/brace-expansion": { "version": "1.1.11", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -2984,7 +3053,6 @@ }, "node_modules/aws-cdk-lib/node_modules/case": { "version": "1.6.3", - "extraneous": true, "inBundle": true, "license": "(MIT OR GPL-3.0-or-later)", "engines": { @@ -2993,7 +3061,6 @@ }, "node_modules/aws-cdk-lib/node_modules/color-convert": { "version": "2.0.1", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -3005,31 +3072,26 @@ }, "node_modules/aws-cdk-lib/node_modules/color-name": { "version": "1.1.4", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/aws-cdk-lib/node_modules/concat-map": { "version": "0.0.1", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/aws-cdk-lib/node_modules/emoji-regex": { "version": "8.0.0", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/aws-cdk-lib/node_modules/fast-deep-equal": { "version": "3.1.3", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/aws-cdk-lib/node_modules/fs-extra": { "version": "11.2.0", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -3043,13 +3105,11 @@ }, "node_modules/aws-cdk-lib/node_modules/graceful-fs": { "version": "4.2.11", - "extraneous": true, "inBundle": true, "license": "ISC" }, "node_modules/aws-cdk-lib/node_modules/ignore": { "version": "5.3.0", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -3058,7 +3118,6 @@ }, "node_modules/aws-cdk-lib/node_modules/is-fullwidth-code-point": { "version": "3.0.0", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -3067,13 +3126,11 @@ }, "node_modules/aws-cdk-lib/node_modules/json-schema-traverse": { "version": "1.0.0", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/aws-cdk-lib/node_modules/jsonfile": { "version": "6.1.0", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -3085,7 +3142,6 @@ }, "node_modules/aws-cdk-lib/node_modules/jsonschema": { "version": "1.4.1", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -3094,13 +3150,11 @@ }, "node_modules/aws-cdk-lib/node_modules/lodash.truncate": { "version": "4.4.2", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/aws-cdk-lib/node_modules/lru-cache": { "version": "6.0.0", - "extraneous": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -3112,7 +3166,6 @@ }, "node_modules/aws-cdk-lib/node_modules/minimatch": { "version": "3.1.2", - "extraneous": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -3124,7 +3177,6 @@ }, "node_modules/aws-cdk-lib/node_modules/punycode": { "version": "2.3.1", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -3133,7 +3185,6 @@ }, "node_modules/aws-cdk-lib/node_modules/require-from-string": { "version": "2.0.2", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -3142,7 +3193,6 @@ }, "node_modules/aws-cdk-lib/node_modules/semver": { "version": "7.5.4", - "extraneous": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -3157,7 +3207,6 @@ }, "node_modules/aws-cdk-lib/node_modules/slice-ansi": { "version": "4.0.0", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -3174,7 +3223,6 @@ }, "node_modules/aws-cdk-lib/node_modules/string-width": { "version": "4.2.3", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -3188,7 +3236,6 @@ }, "node_modules/aws-cdk-lib/node_modules/strip-ansi": { "version": "6.0.1", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -3200,7 +3247,6 @@ }, "node_modules/aws-cdk-lib/node_modules/table": { "version": "6.8.1", - "extraneous": true, "inBundle": true, "license": "BSD-3-Clause", "dependencies": { @@ -3216,7 +3262,6 @@ }, "node_modules/aws-cdk-lib/node_modules/universalify": { "version": "2.0.1", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -3225,7 +3270,6 @@ }, "node_modules/aws-cdk-lib/node_modules/uri-js": { "version": "4.4.1", - "extraneous": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -3234,29 +3278,17 @@ }, "node_modules/aws-cdk-lib/node_modules/yallist": { "version": "4.0.0", - "extraneous": true, "inBundle": true, "license": "ISC" }, "node_modules/aws-cdk-lib/node_modules/yaml": { "version": "1.10.2", - "extraneous": true, "inBundle": true, "license": "ISC", "engines": { "node": ">= 6" } }, - "node_modules/axios": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", - "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", - "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "dev": true, @@ -3392,17 +3424,6 @@ "dev": true, "license": "MIT" }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/concat-map": { "version": "0.0.1", "dev": true, @@ -3462,14 +3483,6 @@ "dev": true, "license": "MIT" }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/detect-libc": { "version": "1.0.3", "license": "Apache-2.0", @@ -3857,38 +3870,6 @@ "dev": true, "license": "ISC" }, - "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -4218,25 +4199,6 @@ "node": ">=8.6" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/minimatch": { "version": "3.1.2", "dev": true, @@ -4611,11 +4573,6 @@ "node": ">=12.0.0" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, "node_modules/punycode": { "version": "2.3.0", "dev": true, From 37b0d4fb1666eed72c6efbea5f5272b3ca9a7c25 Mon Sep 17 00:00:00 2001 From: Giselle van Dongen Date: Thu, 1 Feb 2024 11:57:05 +0100 Subject: [PATCH 2/2] Remove AWS running option: not relevant anymore with Restate CDK. In the future we should make this runnable with CDK --- typescript/ecommerce-store/README.md | 4 - .../ecommerce-store/deployment/aws/.gitignore | 8 - .../ecommerce-store/deployment/aws/README.md | 104 ----------- .../deployment/aws/ecs/main.tf | 164 ------------------ .../deployment/aws/ecs/variables.tf | 19 -- .../ecommerce-store/deployment/aws/main.tf | 147 ---------------- .../deployment/aws/rds/init.sql | 1 - .../deployment/aws/rds/main.tf | 36 ---- .../deployment/aws/rds/variables.tf | 19 -- .../deployment/aws/security-groups/main.tf | 47 ----- .../aws/security-groups/variables.tf | 27 --- .../deployment/aws/services/jaeger/main.tf | 109 ------------ .../aws/services/jaeger/variables.tf | 47 ----- .../deployment/aws/services/pgadmin/main.tf | 98 ----------- .../aws/services/pgadmin/variables.tf | 43 ----- .../aws/services/restate-runtime/main.tf | 111 ------------ .../aws/services/restate-runtime/variables.tf | 67 ------- .../aws/services/shopping-services/main.tf | 126 -------------- .../services/shopping-services/variables.tf | 55 ------ .../deployment/aws/services/webapp/main.tf | 98 ----------- .../aws/services/webapp/variables.tf | 55 ------ .../deployment/aws/terraform.tfvars.template | 10 -- .../deployment/aws/variables.tf | 94 ---------- .../deployment/aws/vpc/main.tf | 85 --------- .../deployment/aws/vpc/variables.tf | 17 -- 25 files changed, 1591 deletions(-) delete mode 100644 typescript/ecommerce-store/deployment/aws/.gitignore delete mode 100644 typescript/ecommerce-store/deployment/aws/README.md delete mode 100644 typescript/ecommerce-store/deployment/aws/ecs/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/ecs/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/main.tf delete mode 120000 typescript/ecommerce-store/deployment/aws/rds/init.sql delete mode 100644 typescript/ecommerce-store/deployment/aws/rds/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/rds/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/security-groups/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/security-groups/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/jaeger/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/jaeger/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/pgadmin/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/pgadmin/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/restate-runtime/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/restate-runtime/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/shopping-services/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/shopping-services/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/webapp/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/services/webapp/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/terraform.tfvars.template delete mode 100644 typescript/ecommerce-store/deployment/aws/variables.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/vpc/main.tf delete mode 100644 typescript/ecommerce-store/deployment/aws/vpc/variables.tf diff --git a/typescript/ecommerce-store/README.md b/typescript/ecommerce-store/README.md index 4f9b4201..cde12fbd 100644 --- a/typescript/ecommerce-store/README.md +++ b/typescript/ecommerce-store/README.md @@ -63,10 +63,6 @@ You can find the Jaeger UI at http://localhost:16686. Have a look at the demo sc You can find the deployment guide for Kubernetes (kind) and Knative [here](./deployment/knative/README.md). -## Deployment on AWS - Fargate - Terraform - -You can find the deployment guide for AWS Fargate [here](./deployment/aws/README.md). - ## Running locally The demo also runs locally. This option doesn't store the products in a Postgres database. diff --git a/typescript/ecommerce-store/deployment/aws/.gitignore b/typescript/ecommerce-store/deployment/aws/.gitignore deleted file mode 100644 index 9d1bddaf..00000000 --- a/typescript/ecommerce-store/deployment/aws/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -terraform.tfvars -.terraform.lock.hcl -.terraform.tfstate.lock.info -terraform.tfstate -shopping-demo-key.pem -.terraform -aws_ec2_instance_public_dns.txt -terraform.tfstate.backup \ No newline at end of file diff --git a/typescript/ecommerce-store/deployment/aws/README.md b/typescript/ecommerce-store/deployment/aws/README.md deleted file mode 100644 index 6c439c80..00000000 --- a/typescript/ecommerce-store/deployment/aws/README.md +++ /dev/null @@ -1,104 +0,0 @@ -# AWS ECS+Fargate deployment with Terraform - -This directory contains Terraform configuration files to spin up the shopping cart demo on AWS ECS + Fargate. - -The AWS architecture looks as follows: - - - -## Prerequisites - -- [Terraform CLI](https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started) -- AWS CLI -- Add your AWS account and credentials (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) to `~/.aws/config` and `~/.aws/credentials`. - -## Pushing the Docker images to ECR - -The following steps need to be executed the first time you want to run the app on Fargate. - -Set your ECR repository URI as an environment variable and log in: - -```shell -export ECR_REPOSITORY= -aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin $ECR_REPOSITORY -``` - -Build the following Docker images and push them to AWS ECR. At the root of the repository, do: - -```shell -# Shopping services -docker build ./services -t $ECR_REPOSITORY/shopping-cart-demo:1.0.2 -docker push $ECR_REPOSITORY/shopping-cart-demo:1.0.2 -# Shopping web app -docker build -t $ECR_REPOSITORY/shopping-cart-webapp:1.0.2 ./react-shopping-cart -docker push $ECR_REPOSITORY/shopping-cart-webapp:1.0.2 -# Restate runtime -docker tag docker.io/restatedev/restate:latest $ECR_REPOSITORY/restate-runtime:latest -docker push $ECR_REPOSITORY/restate-runtime:latest -# Jaeger -docker tag jaegertracing/all-in-one:1.37.0 $ECR_REPOSITORY/jaeger-all-in-one:1.37.0 -docker push $ECR_REPOSITORY/jaeger-all-in-one:1.37.0 -# pgAdmin -docker tag dpage/pgadmin4:6.15 $ECR_REPOSITORY/pgadmin:6.15 -docker push $ECR_REPOSITORY/pgadmin:6.15 -``` - -Rename the `terraform.tfvars.template` file to `terraform.tfvars`. -Then fill in the ECR repository URI under `ecr_repository_uri` in this file. -If you used different version tags, adapt those as well. - -## Deploying on AWS ECS - -Spin up the setup via: - -```shell -terraform init -terraform apply -``` - -**After you have executed this command, you might need to wait a few minutes for all the services to be up.** - -The ECS web UI shows you whether all services came up successfully. - -When everything is running, the SSH key for the EC2 instances can be found under `shopping-demo-key.pem` and the public DNS of the EC2 instance can be found in `aws_ec2_instance_public_dns.txt`. - -**(Temporary fix)**: It is possible that the services were not discovered correctly by the runtime. The -register-services ECS service might come up to early (needs to be fixed). In this case, you can let the runtime discover -the services by ssh'ing to the instance and executing the discovery curl command: - -```shell -chmod 400 shopping-demo-key.pem -ssh -i shopping-demo-key.pem -L 5050:pgadmin.shopping-cart-demo:5050 -L 16686:jaeger.shopping-cart-demo:16686 -L 3000:webapp.shopping-cart-demo:3000 -L 9090:restate-runtime.shopping-cart-demo:9090 ec2-user@`cat aws_ec2_instance_public_dns.txt` -``` - -Then discover the services from within the ssh session: - -```shell -curl -X POST http://restate-runtime.shopping-cart-demo:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://shopping-services.shopping-cart-demo:8080"}' -``` - -This prints out the services were discovered by the Restate runtime. - -## Exposing the UIs - -The ssh command of the previous paragraph also port forwarded the webapp UI, pgAdmin and Jaeger UI: - -- Web app: http://localhost:3000 -- Jaeger: http://localhost:16686 -- pgAdmin: http://localhost:5050 - -To register the database in the pgAdmin UI, have a look at the [README at the root of the ecommerce example](../../README.md#demo-scenario-for-docker-compose-with-postgres). -and replace the `hostname/address` by the RDS database endpoint that you can retrieve -via: - -```shell -aws rds describe-db-instances | jq '.DBInstances[0].Endpoint.Address' -``` - -## Cleanup - -To destroy the setup: - -```shell -terraform destroy -``` diff --git a/typescript/ecommerce-store/deployment/aws/ecs/main.tf b/typescript/ecommerce-store/deployment/aws/ecs/main.tf deleted file mode 100644 index 9a87a705..00000000 --- a/typescript/ecommerce-store/deployment/aws/ecs/main.tf +++ /dev/null @@ -1,164 +0,0 @@ -# ECS cluster + Fargate - -resource "aws_ecs_cluster" "main" { - name = "${var.name}-ecs-cluster" - - setting { - name = "containerInsights" - value = "enabled" - } - - tags = { - Name = "${var.name}-ecs-cluster" - } -} - -resource "aws_iam_role" "ecs_shopping" { - name = "ecs_shopping" - assume_role_policy = <> /etc/ecs/ecs.config -EOF - iam_instance_profile = aws_iam_instance_profile.ecs_shopping.name - vpc_security_group_ids = var.ecs_service_security_groups - key_name = aws_key_pair.shopping_key_pair.key_name - - # write the public DNS to a file to be able to use this later for ssh'ing into the instance - provisioner "local-exec" { - command = "rm -f aws_ec2_instance_public_dns.txt && echo '${self.public_dns}' > aws_ec2_instance_public_dns.txt" - } -} - -resource "aws_iam_role" "ecs_task_execution_role" { - name = "${var.name}-ecsTaskExecutionRole" - - assume_role_policy = <