From 8bd5271c7acfa3878f7f5754764dd8bcece832b3 Mon Sep 17 00:00:00 2001 From: le99 Date: Sat, 1 May 2021 07:36:36 -0500 Subject: [PATCH] Better doc --- README.md | 159 ++++------------------------------------------------- README2.md | 107 +++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 148 deletions(-) create mode 100644 README2.md diff --git a/README.md b/README.md index a4dba6d..b03fa88 100644 --- a/README.md +++ b/README.md @@ -26,161 +26,24 @@ npm install --global --production windows-build-toolsnpm config set msvs_version ## docker-compose - - ```bash -cd ./docker-compose + ./init.sh ./up.sh -cd -``` - -```bash -#Run Sawtooth transaction processor -cd ./tp - npm install - rm ./.env - cp ./.env.docker-compose ./.env - node ./index.js -cd - - - -``` - -Mongo Express to see mongodb: -http://localhost:8081/ - - -```bash - -cd ./app - npm install - rm ./.env - cp ./.env.docker-compose ./.env - - node ./sawtooth-sub-events.js - node ./sawtooth-post.js - node ./sawtooth-get.js - node ./mongo-sample.js - - #kafka - node ./send.js - node ./receive.js - node ./send.js #Repeat -cd - - -``` - -```bash -#Close -cd ./docker-compose ./down.sh -cd - -``` - -## K8s - -```bash -cd ./k8s - ./up-dev.sh -cd - - -#Run Sawtooth transaction processor -cd ./tp - npm install - rm ./.env - cp ./.env.minikube ./.env - node ./index.js -cd - ``` -Mongo Express: -http://192.168.99.100:30081/ +Deploys Kafka, Mongodb and Kafka. +Mongo-express: http://localhost:8081 +Sawtooth-explorer: http://localhost:8091 +Sawtooth-rest-api: http://localhost:8008 -```bash -cd ./app - npm install - rm ./.env - cp ./.env.minikube ./.env - - node ./sawtooth-sub-events.js - node ./sawtooth-post.js - node ./sawtooth-get.js - node ./mongo-sample.js +## Code: +In `./app/` there are scripts to test sawtooth, kafka and mongo. +`tp1` has the transaction procesor (similar to a smart contract). This transaction processor stores a value with a key like a map or hashtable. - #kafka - node ./send.js - node ./receive.js - node ./send.js #Repeat -cd - - - -./down.sh - -``` - -```bash -cd ./k8s - ./down.sh -cd - -``` - -## k8s inside cluster - -```bash -cd ./k8s - ./up.sh -cd - - -./docker-build.sh -``` - -```bash -kubectl run --rm -it borrar --image le999/app:1.0 --restart=Never -- bash - - cp ./.env.k8s ./.env - - node ./sawtooth-sub-events.js - node ./sawtooth-post.js - node ./sawtooth-get.js - node ./mongo-sample.js - - - #kafka - node ./send.js - node ./receive.js - node ./send.js #Repeat - -``` - -```bash -cd ./k8s - ./down.sh -cd - -``` - -## Details - -Only tested with node v10, Im not sure sawtooth SDK works for other versions - - -## Docs Kafka -https://hub.docker.com/r/bitnami/kafka/ -'Accessing Kafka with internal and external clients' - -https://github.com/Blizzard/node-rdkafka -https://kafka.apache.org/quickstart - - -```bash - -docker exec -it kafka_kafka_1 bash -/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --topic mytopic --partitions 1 --replication-factor 1 -/opt/bitnami/kafka/bin/kafka-topics.sh --describe --zookeeper zookeeper:2181 --topic mytopic -/opt/bitnami/kafka/bin/kafka-console-producer.sh --topic mytopic --bootstrap-server localhost:9092 -/opt/bitnami/kafka/bin/kafka-console-consumer.sh --topic mytopic --from-beginning --bootstrap-server localhost:9092 - -``` - +## Suggestions +Edit `up.sh` to only run the code that is required. +Edit `./docker-compose/docker-compose.yaml` so that only the required containers are run \ No newline at end of file diff --git a/README2.md b/README2.md new file mode 100644 index 0000000..6920235 --- /dev/null +++ b/README2.md @@ -0,0 +1,107 @@ +## K8s + +```bash +cd ./k8s + ./up-dev.sh +cd - + +#Run Sawtooth transaction processor +cd ./tp + npm install + rm ./.env + cp ./.env.minikube ./.env + node ./index.js +cd - +``` + +Mongo Express: +http://192.168.99.100:30081/ + + +```bash + +cd ./app + npm install + rm ./.env + cp ./.env.minikube ./.env + + node ./sawtooth-sub-events.js + node ./sawtooth-post.js + node ./sawtooth-get.js + node ./mongo-sample.js + + + #kafka + node ./send.js + node ./receive.js + node ./send.js #Repeat +cd - + + +./down.sh + +``` + +```bash +cd ./k8s + ./down.sh +cd - +``` + +## k8s inside cluster + +```bash +cd ./k8s + ./up.sh +cd - + +./docker-build.sh +``` + +```bash +kubectl run --rm -it borrar --image le999/app:1.0 --restart=Never -- bash + + cp ./.env.k8s ./.env + + node ./sawtooth-sub-events.js + node ./sawtooth-post.js + node ./sawtooth-get.js + node ./mongo-sample.js + + + #kafka + node ./send.js + node ./receive.js + node ./send.js #Repeat + +``` + +```bash +cd ./k8s + ./down.sh +cd - +``` + +## Details + +Only tested with node v10, Im not sure sawtooth SDK works for other versions + + +## Docs Kafka +https://hub.docker.com/r/bitnami/kafka/ +'Accessing Kafka with internal and external clients' + +https://github.com/Blizzard/node-rdkafka +https://kafka.apache.org/quickstart + + +```bash + +docker exec -it kafka_kafka_1 bash +/opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --topic mytopic --partitions 1 --replication-factor 1 +/opt/bitnami/kafka/bin/kafka-topics.sh --describe --zookeeper zookeeper:2181 --topic mytopic +/opt/bitnami/kafka/bin/kafka-console-producer.sh --topic mytopic --bootstrap-server localhost:9092 +/opt/bitnami/kafka/bin/kafka-console-consumer.sh --topic mytopic --from-beginning --bootstrap-server localhost:9092 + +``` +