Have fun 😊 with Go, NodeJS and Kubernetes building a mini blockchain :
- create a simple blockchain,
- encrypt/decrypt its secured content,
- scale and observe it,
- check integrity...
The main purpose of this project is to demonstrate how to communicate between containers in the same Pod using Kubernetes Shared Volumes.
disclaimer : this project is used during TRENDev's workshops and demonstrations.
code-generator
is a Go micro-service continuously generating random secret codes in a JSON file.
The JSON file is shared with the container blockchain
, which uses the secret codes for block content encryption.
The code size (CODE_SIZE) and the refresh delay (DELAY) can be set as Environment variables.
docker build -t trendev/code-generator . && docker push trendev/code-generator
blockchain
is a NodeJS micro-service.
It's a simple Rest API, used to:
- add secured block,
- get secured content,
- check overall integrity.
Before a block is created and added in the chain, its content is encrypted with a random secret code (generated by code-generator
container).
Then, when the block is added, the secret code is provided in the HTTP response.
As the secret code is changed many times in a second, if the provided secret code is lost, the block content cannot be decrypted...
The blockchain is initialized with few first blocks. The number of the first seeds (N_SEED) and the port of the API services (PORT) can be set as Environment variables.
docker build -t trendev/blockchain . && docker push trendev/blockchain
You've to apply the content of k8s/
folder:
- create the
Namespace
- create the
NodePort Service
- create the
Pod
with 2 containerscode-generator
andblockchain
Test settings can be edited in order to reflect your own configuration:
- edit the value
URL
in the filemini-blockchain.postman_environment.json
with your NodePort settings (http://{NodeIP}:{NodePort})
test files are located in blockchain > test > pm
newman run mini-blockchain.postman_collection.json -e mini-blockchain.postman_environment.json -n 100
... and you should get the following result :