This is the third step in the setup process for this project.
A Hyperledger Fabric network is deployed on kubernetes cluster. This network is highly customizable and various parameters can be altered during creation time e.g. network size, fabric version etc
Each "Organisation" is matched to a "Namespace" in kubernetes. There are 2 types of organisation: Peer organisations and Orderer organisation.
Ansible is used as the automation tool.
Code location
- hyperledger/roles/: Ansible roles for different steps performed in create fabric network and delete fabric network
Ansible Playbook: blockchain_setup.yaml
Command: ansible-playbook -i inventory/blockchain/hosts.ini -v blockchain_setup.yaml
Variables:
- Defined in file: blockchain-setup.yaml
- Fabric binary/image:
fabric_version
: Version of fabric to use, default=1.4.0fabric_ca_version
: Version of fabric ca binary, default=fabric_version
fabric_couchdb_version
: Version of couchdb, kafka and zookeerper, default=0.4.14fabric_images
: A dictonary defines docker images of various fabric components i.e ca, peer, tools, orderer, couchdb, kafka, zookeerper and dind
- Fabric network:
fabric_create_cli
: Create a fabric cli pod in each organisation, default=false
fabric_num_orgs
: Number of peer organisations, default=2
fabric_peers_per_org
: Number of fabric peers per organisation, default=2
fabric_state_db
: Database to be used a StateDB in fabric peer, default=couchdb
. Options=couchdb/goleveldb
fabric_orderer_type
: Type of consensus to use in orderer, default=solo
. Options=solo/kafka
fabric_num_kafka
: Number of kafka pods, default=3
. Created only iffabric_orderer_type=kafka
fabric_num_zookeeper
: Number of zookeeper pods, default=3
. Created only iffabric_orderer_type=kafka
- Fabric ledger:
fabric_batch_timeout
: Batch Timeout: The amount of time to wait before creating a batchfabric_batchsize
: Batch Size: Controls the number of messages batched into a block
- Metrics config:
metrics_network_file
: Location of fabric network file generated for Caliperchannels
: Defines a list of channels to create and chaincodes installed on the channels
This command will call blockchain_setup.yaml playbook, which will perform 4 steps:
- Configure Fabric:
- Playbook: playbooks/configure_fabric.yaml
- Role: hyperledger/roles/network_config
- Mount NFS server on CLI
- Use fabric binaries for version defined in
fabric_version
- Generate configtx.yaml and crypto-config.yaml based on fabric network variable explained above
- Create crypto configuration and orderer artifcats using fabric binaries "cryptogen" and "configtxgen"
- Copy above configuration to NFS mount
- Generate kubernetes templates for various resources, using generate_k8s_configs.py script and k8s templates
- Install Fabric:
- Playbook: playbooks/install_fabric.yaml
- Role: hyperledger/roles/network_setup
- Deploy k8s resources for fabric componenets to the k8s cluster, using create_k8s_blockchain.py script.
- Install a Fabric channel and join all peers to it:
- Playbook: playbooks/setup_fabric_channel.yaml
- role: hyperledger/roles/channel_setup
- Create a test channel on the fabric network deployed on k8s cluster.
- Add all peers to this channel.
- Update anchor peer for each organisation.
- Create configuration for metrics framework:
- Playbook: playbooks/create_metrics_config.yaml
- Role: hyperledger/roles/metrics_config
- Create a fabric network file for Caliper and store it in
metrics_network_file
location using template fabric_ccp_network.yaml.j2- All channels defnined in
channels
dictionary will be created - All chaincode are defnined per channel in
channels
dictionary - Caliper needs this file to communicate with Fabric network via Common Connection Profile (CCP) of fabric-sdk. See documentation
- An example of network config file created can be found here: fabric_ccp_network.yaml
- All channels defnined in
- Make entries in etc/hosts for CLI with pseudo dns of peer and orderer domain to k8s worker nodes
- Example of entries made in /etc/hosts can be found here: etc_hosts
- All configurations generated for Fabric network are located in inventory/blockchain/fabric-config directory
- Metrics network configuration is located at
inventory/blockchain/fabric_ccp_network.yaml
or as defined inmetrics_network_file
setting.
Ansible Playbook: blockchain_delete.yaml
Command: ansible-playbook -i inventory/blockchain/hosts.ini -v blockchain_delete.yaml
Variables:
- Defined in file: blockchain-setup.yaml
This command will call blockchain_delete.yaml playbook, which will:
- Delete the NFS mount from CLI
- Delete all fabric configurations generated during "Create Fabric Network"
- Delete fabric network from kubernetes cluster, using delete_k8s_blockchain.py script.