Address review feedback - better prereq checks

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
This commit is contained in:
Josh Kneubuhl 2022-05-03 11:00:16 -04:00 committed by Dave Enyeart
parent 9ca1cc7c63
commit 49fa452864
5 changed files with 47 additions and 20 deletions

View file

@ -17,10 +17,11 @@ _Fabric, Ahoy!_
## Prerequisites
- [Docker](https://www.docker.com)
- [kubectl](https://kubernetes.io/docs/tasks/tools/)
- K8s: [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) or [k3s](https://rancherdesktop.io)
- [Docker](https://www.docker.com)
- K8s: [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) or [Rancher / k3s](https://rancherdesktop.io)
- [jq](https://stedolan.github.io/jq/)
- [envsubst](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html) (`brew install gettext` on OSX)
## Quickstart
@ -29,13 +30,28 @@ Create a KIND Kubernetes:
```shell
./network kind
```
Or for environments running [Rancher k3s](docs/KUBERNETES.md#rancher-desktop-and-k3s):
For environments running [Rancher k3s](docs/KUBERNETES.md#rancher-desktop-and-k3s):
```shell
export TEST_NETWORK_CLUSTER_RUNTIME=k3s
./network cluster-init
```
Fabric services are exposed by Kubernetes Ingress at the fictitious DNS domain `*.local.fabric`. Add the
following aliases to your /etc/hosts file:
```
127.0.0.1 org0-ca.local.fabric
127.0.0.1 org1-ca.local.fabric
127.0.0.1 org2-ca.local.fabric
127.0.0.1 org0-orderer1.local.fabric
127.0.0.1 org0-orderer2.local.fabric
127.0.0.1 org0-orderer3.local.fabric
127.0.0.1 org1-peer1.local.fabric
127.0.0.1 org1-peer2.local.fabric
127.0.0.1 org2-peer1.local.fabric
127.0.0.1 org2-peer2.local.fabric
```
Launch the network, create a channel, and deploy the [basic-asset-transfer](../asset-transfer-basic) smart contract:
```shell
./network up
@ -75,10 +91,3 @@ Tear down the cluster:
- [Working with Chaincode](docs/CHAINCODE.md)
- [Working with Applications](docs/APPLICATIONS.md)
## Areas for Improvement / TODOs
- [ ] Test the recipe with OCP, AWS, gcp, Azure, etc. (These should ONLY differ w.r.t. pvc and ingress)
- [ ] Address any of the 20+ todo: notes in network.sh
- [ ] Implement mutual TLS across peers, orderers, and clients.
- [ ] Caliper?

View file

@ -27,7 +27,7 @@ export FABRIC_PEER_IMAGE=${TEST_NETWORK_FABRIC_PEER_IMAGE:-${FABRIC_CONTAINER_RE
export NETWORK_NAME=${TEST_NETWORK_NAME:-test-network}
export CLUSTER_NAME=${TEST_NETWORK_KIND_CLUSTER_NAME:-kind}
export NS=${TEST_NETWORK_KUBE_NAMESPACE:-${NETWORK_NAME}}
export DOMAIN=${TEST_NETWORK_DOMAIN:-vcap.me}
export DOMAIN=${TEST_NETWORK_DOMAIN:-local.fabric}
export CHANNEL_NAME=${TEST_NETWORK_CHANNEL_NAME:-mychannel}
export TEMP_DIR=${PWD}/build

View file

@ -16,11 +16,8 @@ function init_namespace() {
function init_storage_volumes() {
push_fn "Provisioning volume storage"
# odd.
# KIND runs the rancher local-path provider, installing as the storageclass 'standard'
# Rancher runs the local-path provider, installing as the storageclass 'local-path'
#
# When installing to KIND, use the 'standard' storage class.
# Both KIND and k3s use the Rancher local-path provider. In KIND, this is installed
# as the 'standard' storage class, and in Rancher as the 'local-path' storage class.
if [ "${CLUSTER_RUNTIME}" == "kind" ]; then
export STORAGE_CLASS="standard"

View file

@ -16,10 +16,12 @@ function check_prereqs() {
exit 1
fi
kind version > /dev/null
if [[ $? -ne 0 ]]; then
echo "No 'kind' binary available? (https://kind.sigs.k8s.io/docs/user/quick-start/#installation)"
exit 1
if [ "${CLUSTER_RUNTIME}" == "kind" ]; then
kind version > /dev/null
if [[ $? -ne 0 ]]; then
echo "No 'kind' binary available? (https://kind.sigs.k8s.io/docs/user/quick-start/#installation)"
exit 1
fi
fi
kubectl > /dev/null
@ -34,6 +36,12 @@ function check_prereqs() {
exit 1
fi
echo | envsubst > /dev/null
if [[ $? -ne 0 ]]; then
echo "No 'envsubst' binary (gettext package) available? (https://www.gnu.org/software/gettext/)"
exit 1
fi
# Use the local fabric binaries if available. If not, go get them.
bin/peer version &> /dev/null
if [[ $? -ne 0 ]]; then

View file

@ -210,8 +210,21 @@ function scrub_org_volumes() {
}
function network_down() {
set +e
kubectl get namespace $NS > /dev/null
if [[ $? -ne 0 ]]; then
echo "No namespace $NS found - nothing to do."
return
fi
set -e
stop_services
scrub_org_volumes
kubectl delete namespace $NS
rm -rf $PWD/build
}