From 0db64487e5e89a81d68e6871af3f0907c67e7d75 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Mon, 29 Apr 2024 11:46:37 +0100 Subject: [PATCH] Update nano test network Fix regression in network.sh and update peer scripts to allow chaincodeListenAddress and chaincodeAddress to be overridden if required Also updates the nano test network readme to describe the new environment variables for the k8s builder Fixes #1198 Signed-off-by: James Taylor --- test-network-nano-bash/README.md | 12 ++++++++++++ test-network-nano-bash/network.sh | 8 ++++---- test-network-nano-bash/peer1.sh | 4 ++-- test-network-nano-bash/peer2.sh | 4 ++-- test-network-nano-bash/peer3.sh | 4 ++-- test-network-nano-bash/peer4.sh | 4 ++-- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/test-network-nano-bash/README.md b/test-network-nano-bash/README.md index c968ccce..7d276ecc 100644 --- a/test-network-nano-bash/README.md +++ b/test-network-nano-bash/README.md @@ -87,6 +87,7 @@ To deploy and invoke the chaincode, utilize the peer1 admin terminal that you ha 1. Using a chaincode container 2. Running the chaincode as a service +3. Using the k8s builder and minikube For your convenience you can run `install&approve&commit_chaincode_peer1.sh` from peer1admin terminal to run basic chaincode as a container and activate it. The output of the script is redirected to the logs folder. @@ -154,6 +155,17 @@ And start the chaincode service: npm run start:server-nontls ``` +## 3. Using the k8s builder and minikube + +It is also possible to launch chaincode in kubernetes pods using the k8s builder. A simple way to do this is using [minikube](https://minikube.sigs.k8s.io/docs/), which requires the chaincodeListenAddress and chaincodeAddress settings used by the Nano test network to be overridden using the following environment variables. + +```shell +export CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE=host.minikube.internal +export CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE=0.0.0.0 +``` + +See the [fabric-builder-k8s](https://github.com/hyperledger-labs/fabric-builder-k8s) project for more details on how to configure and use the k8s builder. + ## Activate the chaincode Using the peer1 admin, approve and commit the chaincode (only a single approver is required based on the lifecycle endorsement policy of any organization): diff --git a/test-network-nano-bash/network.sh b/test-network-nano-bash/network.sh index fb2fa80f..288a1cf0 100755 --- a/test-network-nano-bash/network.sh +++ b/test-network-nano-bash/network.sh @@ -95,16 +95,16 @@ networkStart() { fi echo "Creating channel (peer1)..." - . peer1admin.sh && ./join_channel.sh + . ./peer1admin.sh && ./join_channel.sh echo "Joining channel (peer2)..." - . peer2admin.sh && ./join_channel.sh + . ./peer2admin.sh && ./join_channel.sh echo "Joining channel (peer3)..." - . peer3admin.sh && ./join_channel.sh + . ./peer3admin.sh && ./join_channel.sh echo "Joining channel (peer4)..." - . peer4admin.sh && ./join_channel.sh + . ./peer4admin.sh && ./join_channel.sh fi echo "Fabric network running. Use Ctrl-C to stop." diff --git a/test-network-nano-bash/peer1.sh b/test-network-nano-bash/peer1.sh index 7f53cfc1..e6b147b5 100755 --- a/test-network-nano-bash/peer1.sh +++ b/test-network-nano-bash/peer1.sh @@ -22,8 +22,8 @@ export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}"/crypto-config/peerOrganizations/org1 export CORE_PEER_ID=peer0.org1.example.com export CORE_PEER_ADDRESS=127.0.0.1:7051 export CORE_PEER_LISTENADDRESS=127.0.0.1:7051 -export CORE_PEER_CHAINCODEADDRESS="${CCADDR}":7052 -export CORE_PEER_CHAINCODELISTENADDRESS=127.0.0.1:7052 +export CORE_PEER_CHAINCODEADDRESS="${CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE:-${CCADDR}}":7052 +export CORE_PEER_CHAINCODELISTENADDRESS="${CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE:-127.0.0.1}":7052 # bootstrap peer is the other peer in the same org export CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7053 export CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7051 diff --git a/test-network-nano-bash/peer2.sh b/test-network-nano-bash/peer2.sh index bbd64864..6d1548df 100755 --- a/test-network-nano-bash/peer2.sh +++ b/test-network-nano-bash/peer2.sh @@ -22,8 +22,8 @@ export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}"/crypto-config/peerOrganizations/org1 export CORE_PEER_ID=peer1.org1.example.com export CORE_PEER_ADDRESS=127.0.0.1:7053 export CORE_PEER_LISTENADDRESS=127.0.0.1:7053 -export CORE_PEER_CHAINCODEADDRESS="${CCADDR}":7054 -export CORE_PEER_CHAINCODELISTENADDRESS=127.0.0.1:7054 +export CORE_PEER_CHAINCODEADDRESS="${CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE:-${CCADDR}}":7054 +export CORE_PEER_CHAINCODELISTENADDRESS="${CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE:-127.0.0.1}":7054 # bootstrap peer is the other peer in the same org export CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7051 export CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7053 diff --git a/test-network-nano-bash/peer3.sh b/test-network-nano-bash/peer3.sh index 50d79b9f..7c4367a7 100755 --- a/test-network-nano-bash/peer3.sh +++ b/test-network-nano-bash/peer3.sh @@ -22,8 +22,8 @@ export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}"/crypto-config/peerOrganizations/org2 export CORE_PEER_ID=peer0.org2.example.com export CORE_PEER_ADDRESS=127.0.0.1:7055 export CORE_PEER_LISTENADDRESS=127.0.0.1:7055 -export CORE_PEER_CHAINCODEADDRESS="${CCADDR}":7056 -export CORE_PEER_CHAINCODELISTENADDRESS=127.0.0.1:7056 +export CORE_PEER_CHAINCODEADDRESS="${CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE:-${CCADDR}}":7056 +export CORE_PEER_CHAINCODELISTENADDRESS="${CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE:-127.0.0.1}":7056 # bootstrap peer is the other peer in the same org export CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7057 export CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7055 diff --git a/test-network-nano-bash/peer4.sh b/test-network-nano-bash/peer4.sh index 3dc80d2c..a78e9d6b 100755 --- a/test-network-nano-bash/peer4.sh +++ b/test-network-nano-bash/peer4.sh @@ -22,8 +22,8 @@ export CORE_PEER_TLS_ROOTCERT_FILE="${PWD}"/crypto-config/peerOrganizations/org2 export CORE_PEER_ID=peer1.org2.example.com export CORE_PEER_ADDRESS=127.0.0.1:7057 export CORE_PEER_LISTENADDRESS=127.0.0.1:7057 -export CORE_PEER_CHAINCODEADDRESS="${CCADDR}":7058 -export CORE_PEER_CHAINCODELISTENADDRESS=127.0.0.1:7058 +export CORE_PEER_CHAINCODEADDRESS="${CORE_PEER_CHAINCODEADDRESS_HOST_OVERRIDE:-${CCADDR}}":7058 +export CORE_PEER_CHAINCODELISTENADDRESS="${CORE_PEER_CHAINCODELISTENADDRESS_HOST_OVERRIDE:-127.0.0.1}":7058 # bootstrap peer is the other peer in the same org export CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7055 export CORE_PEER_GOSSIP_EXTERNALENDPOINT=127.0.0.1:7057