From 5ff66541244ff54ea53f589e62652ee83f5edc3d Mon Sep 17 00:00:00 2001 From: mbw Date: Fri, 24 Jun 2022 12:24:29 +0000 Subject: [PATCH] Suggested updates to the sample network readme Therese are some suggested updates to make the overall 'flow' of the readme.md better. So it easier for Fred/Fiona to follow along. Also added a way of 'cheating' if you been through the tutorial before, then just a quick recap of the commands is useful Signed-off-by: mbw --- sample-network/README.md | 42 ++++++++++++++++++----- sample-network/justfile | 57 +++++++++++++++++++++++++++++++ sample-network/scripts/console.sh | 3 +- 3 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 sample-network/justfile diff --git a/sample-network/README.md b/sample-network/README.md index 5e5713c1..7af2b7e6 100644 --- a/sample-network/README.md +++ b/sample-network/README.md @@ -12,20 +12,47 @@ Feedback, comments, questions, etc. at Discord : [#fabric-kubernetes](https://di ![sample-network](../docs/images/fabric-operator-sample-network.png) -## Prerequisites: +## Essential Setup -### General +### Clone this repo + +Remeber to clone this repo and change to the `sample-network` directory + +```shell +git clone https://github.com/hyperledger-labs/fabric-operator.git +cd fabric-operator/sample-network +``` + +### Required Tools + +If you don't have these already, please install these first. - [kubectl](https://kubernetes.io/docs/tasks/tools/) - [jq](https://stedolan.github.io/jq/) - [envsubst](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html) (`brew install gettext` on OSX) -- [k9s](https://k9scli.io) (recommended) -- Fabric binaries (peer, osnadmin, etc.) will be installed into the local `bin` folder. Add these to your PATH: +Note that the Fabric binaries (peer, osnadmin, etc.) will be installed for you into a local `bin` folder. These should be added to your PATH: ```shell export PATH=$PWD:$PWD/bin:$PATH ``` +### Optional Tools + +These are optional but strongly recommended; especially if you want to run a local cluster. + +- [kind](https://kind.sigs.k8s.io/) if you want to create a cluster locally, see below for other options +- [k9s](https://k9scli.io) (recommended, but not essential) +- [just](https://github.com/casey/just#installation) to run all the comamnds here directly + +If you've run this tutorial before, there is a `justfile` that can used as a helpful 'cheatsheet' of the commands. If you have `just` installed then a `just everything` will setup everything! +For all the available recipies just run `just` +```shell +Available recipes: + cluster # Starts and configures a local KIND cluster + everything # Cluster and Fabric Network + network # Installs and configures a sample Fabric Network + unkind # Removes the local cluster +``` ### Kubernetes @@ -63,9 +90,7 @@ export TEST_NETWORK_INGRESS_DOMAIN=test-network.example.com For additional guidelines on configuring ingress and DNS, see [Considerations for Kubernetes Distributions](https://cloud.ibm.com/docs/blockchain-sw-252?topic=blockchain-sw-252-deploy-k8#console-deploy-k8-considerations). - - -## Sample Network +## Starting the Sample Network Install the Nginx controller and Fabric CRDs: ```shell @@ -82,8 +107,7 @@ Explore Kubernetes `Pods`, `Deployments`, `Services`, `Ingress`, etc.: kubectl -n test-network get all ``` - -## Chaincode +## Deploying Chaincode In the examples below, the `peer` binary will be used to invoke smart contracts on the org1-peer1 ledger. Set the CLI context with: ```shell diff --git a/sample-network/justfile b/sample-network/justfile new file mode 100644 index 00000000..f559a8c1 --- /dev/null +++ b/sample-network/justfile @@ -0,0 +1,57 @@ +# Apache-2.0 + +# Main justfile to run all the scripts +# +# To install 'just' see https://github.com/casey/just#installation + + +# Ensure all properties are exported as shell env-vars +set export + +# set the current directory, and the location of the test dats +CWDIR := justfile_directory() + +_default: + @just --list + +# Starts and configures a local KIND cluster +cluster: + #!/bin/bash + set -ex -o pipefail + + # create and configure the cluster + ./network kind + ./network cluster init + +# Installs and configures a sample Fabric Network +network: + #!/bin/bash + set -ex -o pipefail + + # create Fabric network + ./network up + + kubectl -n test-network get all + + # create Fabric channnel + ./network channel create + +# Cluster and Fabric Network +everything: cluster network + +# Install the operations console +console: + #!/bin/bash + set -ex -o pipefail + + ./network console + +# Installs just the operator +operator: + #!/bin/bash + + ./network operator + +# Removes the local cluster +unkind: + ./network unkind diff --git a/sample-network/scripts/console.sh b/sample-network/scripts/console.sh index 4d696229..7fc3c362 100644 --- a/sample-network/scripts/console.sh +++ b/sample-network/scripts/console.sh @@ -28,10 +28,11 @@ function console_up() { wait_for_deployment hlf-console local console_hostname=${NS}-hlf-console-console - local console_url="https://${CONSOLE_USERNAME}:${CONSOLE_PASSWORD}@${console_hostname}.${CONSOLE_DOMAIN}" + local console_url="https://${console_hostname}.${CONSOLE_DOMAIN}" log "" log "The Fabric Operations Console is available at ${console_url}" + log "Default user is \"${CONSOLE_USERNAME}\" with passworld \"${CONSOLE_PASSWORD}\"" log "" # TODO: prepare an FoC bulk JSON import for the test network assets