Skip to content

Latest commit

 

History

History
208 lines (152 loc) · 5.11 KB

README.md

File metadata and controls

208 lines (152 loc) · 5.11 KB

Hyperledger Fabric Kubernetes Test Network

Create a Hyperledger Fabric test-network on KIND with fabric-operator.

Objective: provide crystal clarity to Fabric's MSP and certificate structures, focusing on the inductive construction of a multi-organization channel.

Dark Side of the Moon

The Dark Side of the Moon - Pink Floyd (From Wikipedia, the free encyclopedia )

Venue:

To run this sample locally, clone the git repo and follow the dependency checklist:

./scripts/check.sh

On x86 / amd64 system, the sample can also be run within a self-contained multipass virtual machine:

multipass launch \
  --name        fabric-dev \
  --disk        80G \
  --cpus        8 \
  --mem         8G \
  --cloud-init  https://raw.githubusercontent.com/hyperledgendary/fabric-kube-test-network/main/cloud-config.yaml
multipass shell fabric-dev

(Note: fabric binaries are not available for the Apple M1 / arm64 architecture.)

For best results, start a new terminal for each organization in the consortium. Imagine that each shell is running commands on behalf of the org's Fabric administrator.

Stage:

git clone https://github.com/hyperledgendary/fabric-kube-test-network.git
cd fabric-kube-test-network

Create a KIND kubernetes cluster, *.localho.st ingress, and local container registry:

just kind 

Act I: Launch CAs, peers, and orderers

Start the nodes in the network:

just start org0
just start org1
just start org2

Enroll admin, rcaadmin, and gateway users at the org CAs:

just enroll org0
just enroll org1
just enroll org2
just check-network

Act II: Build a Consortium

just export-msp org0
just export-msp org1
just export-msp org2
just create-genesis-block

just inspect-genesis-block
just join org0
just join org1
just join org2

Act III: Chaincode and Gateway Application

Install asset-transfer version 0.1.4 with the Kubernetes chaincode builder:

just install-cc org1
just install-cc org2

Ad Hoc peer CLI:

org1:

export ORG=org1
export MSP_ID=Org1MSP 

source <(just show-context $MSP_ID $ORG peer1)

peer chaincode query \
  -n asset-transfer \
  -C mychannel \
  -c '{"Args":["org.hyperledger.fabric:GetMetadata"]}'  

org2:

export ORG=org2
export MSP_ID=Org2MSP 

source <(just show-context $MSP_ID $ORG peer1) 

peer chaincode query \
  -n asset-transfer \
  -C mychannel \
  -c '{"Args":["org.hyperledger.fabric:GetMetadata"]}' 

Gateway Client

When the org1 and org2 CAs are created, they include a bootstrap registration and enrollment of a client identity for use in gateway application development.

If the just show-context commands (above) have been loaded into the terminal, the peer, orderer, and CA certificate paths have been loaded into the environment.

In an org admin shell, load the gateway client environment for trader-typescript:

# local MSP enrollment folder for the org client user
export USER_MSP_DIR=$PWD/organizations/$ORG/enrollments/${ORG}user/msp

# Path to private key file 
export PRIVATE_KEY=$USER_MSP_DIR/keystore/key.pem

# Path to user certificate file
export CERTIFICATE=$USER_MSP_DIR/signcerts/cert.pem

# Path to CA certificate
export TLS_CERT=$CORE_PEER_TLS_ROOTCERT_FILE

# Connect client applications to the load-balancing gateway peer alias:
export ENDPOINT=${ORG}-peer-gateway.${ORG}.localho.st:443
  • Compile the trader-typescript application:
git clone https://github.com/hyperledger/fabric-samples.git /tmp/fabric-samples 
pushd /tmp/fabric-samples/full-stack-asset-transfer-guide/applications/trader-typescript

npm install
# Create a yellow banana token
npm start create banana bananaman yellow

npm start getAllAssets

# Transfer the banana among users / orgs 
npm start transfer banana appleman Org1MSP

npm start getAllAssets

# Transfer the banana among users / orgs 
npm start transfer banana bananaman Org2MSP

# Error! Which org owns the banana? 
npm start transfer banana bananaman Org1MSP

Teardown

# Tear down the network 
just destroy

or

# Tear down the kubernetes cluster
just unkind

or

# Tear down the multipass VM: 
multipass delete fabric-dev
multipass purge