hlf-k8s

by Substra

Helm chartv10.2.4Verified publisher

Substra tools to configure the hyperledger fabric network

About this chart

HLF k8s

HLF-k8s is a network of Hyperledger Fabric orderers and peers, forming a permissioned blockchain.

The network is formed of multiple nodes (peers/orderers). Each node is installed using the same chart, but with different configurations (see Usage).

Hlf-k8s runs Hyperledger Fabric v2.x

Prerequisites

  • Kubernetes 1.16+

Changelog

See CHANGELOG.md

Configuration

The following table lists the configurable parameters of the hlf-k8s chart and default values.

ParameterDescriptionDefault
Peer
hlf-peer.enabledIf true, a HLF Peer will be installedtrue
hlf-peer.peer.mspIDID of MSP the Peer belongs toOrg1MSP
hlf-peer.discover-monitor.enabledIf true, create a discover monitor pod (see Monitoring pods)false
hlf-peer.peer.gossip.externalEndpointHLF peer gossip external endpoint""
hlf-peer.peer.databaseTypeDatabase type to use (goleveldb or CouchDB)CouchDB
hlf-peer.peer.couchdbSecretSecret holding the couchdb credentialscdb-peer-hlf-k8s-couchdb-credentials
hlf-peer.peer.couchdbInstanceCouchDB chart name to use cdb-peercdb-peer
hlf-peer.hostThe Peers's hostpeer-hostname
hlf-peer.portThe Peers's port7051
hlf-peer.peer.docker.enabledIf true, mount host docker socket in the peer containerfalse
hlf-peer.ingress.enabledIf true, Ingress will be created for the Peerfalse
hlf-peer.ingress.annotationsPeer ingress annotationsnil
hlf-peer.ingress.tlsPeer ingress TLS configurationnil
hlf-peer.ingress.hostsPeer ingress hostsnil
hlf-peer.persistence.enabledIf true, enable persistence for the Peertrue
hlf-peer.persistence.sizeSize of data volume10Gi
hlf-peer.persistence.storageClassStorage class of backing PVCnil
appChannelsThe application channels to create[{channelName: mychannel}]
appChannels[].channelNameThe name of the application channel. Must be alphanumerical (9 characters max.)nil
appChannels[].organizationsThe organizations to add to the application channel. See Add an organization to the application channel.[]
appChannels[].proposalOrganizationsThe organizations to fetch signed application channel update proposals from.[]
appChannels[].channelPoliciesThis value overrides the default HLF channel policy.(defined in values.yaml)
appChannels[].appPoliciesThis value overrides the default HLF application policy.(defined in values.yaml)
appChannels[].chaincodesThe chaincodes to install on the Peer. See Install a chaincode.[]
appChannels[].chaincodes[].nameThe name of the chaincodenil
appChannels[].chaincodes[].versionThe chaincode versionnil
appChannels[].chaincodes[].sequenceThe chaincode sequencenil
appChannels[].chaincodes[].policyThe chaincode policy for this channelnil
appChannels[].ingress.enabledIf true, Ingress will be created for this application channel operator.false
appChannels[].ingress.annotationsApplication channel operator ingress annotationsnil
appChannels[].ingress.tlsApplication channel operator ingress TLS configurationnil
appChannels[].ingress.hostsApplication channel operator ingress hostsnil
appChannels[].ingress.ingressClassNameIngress class that will be used for the ingressnil
appChannels[].ingress.pathTypeIngress path typenil
chaincodesThe chaincodes to install on the peer[]
chaincodes[].nameThe name of the chaincodenil
chaincodes[].versionThe chaincode versionnil
chaincodes[].addressThe URL to the chaincode servicenil
chaincodes[].portThe port to the chaincode servicenil
chaincodes[].logLevelThe log level for the chaincode processnil
chaincodes[].image.repositorychaincode image repositorynil
chaincodes[].image.tagchaincode image tagnil
chaincodes[].image.pullPolicyImage pull policynil
chaincodes[].image.pullImageSecretImage pull secret namenil
chaincodes[].init.image.repositoryoptional chaincode's initContainer image repositorynil
chaincodes[].init.image.tagoptional chaincode's initContainer image tagnil
configOperator.ingress.enabledIf true, Ingress will be created for the config operator.false
configOperator.ingress.annotationsConfig operator ingress annotationsnil
configOperator.ingress.tlsConfig operator ingress TLS configurationnil
configOperator.ingress.hostsConfig operator ingress hostsnil
configOperator.ingress.ingressClassNameIngress class that will be used for the ingressnil
configOperator.ingress.pathTypeIngress path typeImplementationSpecific
genesis.generateIf true, generate a HLF genesis block and populate the secrets.genesis secrettrue
Orderer
hlf-ord.enabledIf true, a HLF Orderer will be installedfalse
hlf-ord.hostThe hostname for the Ordererorderer-hostname
hlf-ord.portThe Orderer's port7050
hlf-ord.ord.mspIDID of MSP the Orderer belongs toMyOrdererMSP
hlf-ord.monitor.enabledIf true, create a monitor pod (see Monitoring pods)false
hlf-ord.ingress.enabledIf true, Ingress will be created for the Orderernil
hlf-ord.ingress.annotationsOrderer ingress annotationsnil
hlf-ord.ingress.tlsOrderer ingress TLS configurationnil
hlf-ord.ingress.hostsOrderer ingress hostsnil
hlf-ord.persistence.enabledIf true, enable persistence for the Orderertrue
hlf-ord.persistence.sizeSize of data volume10Gi
hlf-ord.persistence.storageClassStorage class of backing PVCnil
systemChannel.nameThe name of the system channelsystemchannel
systemChannel.organizationsThe organizations to add to the system channel. See Add an organization to the system channel.[]
Common / Other
fabric-tools.image.repositoryfabric-tools image repositorygcr.io/connect-314908/fabric-tools
fabric-tools.image.tagfabric-tools image tag0.2.4
fabric-tools.image.pullPolicyImage pull policyIfNotPresent
fabric-tools.image.pullImageSecretImage pull secret namenil
nodeSelectorNode labels for pod assignment{}
tolerationsToleration labels for pod assignment[]
affinityAffinity settings for pod assignment{}
organization.idThe organization idMyOrganizationMSP
organization.nameThe organization nameMyOrganization
enrollments.credsThe users to enroll with the CA[]
enrollments.csrHostThe value to pass to --csr.hosts when enrolling users to the CAservice-hostname
hlf-ca.caNameName of CArca
hlf-ca.schemeCA schemehttp
hlf-ca.hostCA hostca-hostname
hlf-ca.portCA port7054
hlf-ca.orderer.schemeOrderer's CA schemehttp
hlf-ca.orderer.hostOrderer's CA hostorderer-ca-hostname
hlf-ca.orderer.portOrderer's CA port7054
hlf-ca.persistence.enabledIf true, enable persistence for the CAtrue
hlf-ca.persistence.sizeSize of data volume5Gi
hlf-ca.persistence.storageClassStorage class of backing PVCnil
couchdb.image.repositorycouchdb image repositoryhyperledger/fabric-couchdb
couchdb.image.tagcouchdb image tag0.4.21
couchdb.image.pullPolicyImage pull policyIfNotPresent
couchdb.service.portTCP port5984
couchdb.service.typeK8S service type exposing ports, e.g. ClusterIPClusterIP
couchdb.persistence.sizeSize of data volume (adjust for production!)10Gi
couchdb.persistence.storageClassStorage class of backing PVCdefault
couchdb.couchdbUsernameUsername for CouchDBcouchdb
couchdb.couchdbPasswordPassword for CouchDBcouchdbpwd
privateCa.enabledif true, use a private CAfalse
privateCa.configMap.nameThe name of the ConfigMap containing the private CA certificateprivate-ca
privateCa.configMap.fileNameThe CA certificate filename within the ConfigMapprivate-ca.crt
hooks.deleteSecrets.enabledIf true, the HLF crypto materials secrets created by the chart will be automatically deleted when the chart is uninstalledtrue
hooks.deleteCCIDSecrets.enabledIf true, the chaincode ccid secrets created by the chart will be automatically deleted when the chart is uninstalledtrue
hooks.serviceAccount.nameserviceAccount used for the post-delete hooks, must be able to delete secrets""
hooks.serviceAccount.namespacenamespace of the serviceAccount used for the post-delete hook, this will define the namespace in which the hook job run (if unset it will be replaced by the release namespace)""
toolbox.enabledIf true, a "toolbox" pod will be created with pre-installed utilities and certificatesfalse

Usage

Basic example

For an example using 1 orderer and 2 peers, see the skaffold.yaml file.

Install a chaincode

Install a chaincode on a peer using the following values.

On a peer:

chaincodes:
  - name: mycc
    version: "1.0"
    address: "chaincode-org-1-substra-chaincode-chaincode.org-1.svc.cluster.local"
    port: "7052"
    image:
      repository: substra/orchestrator-chaincode
      tag: 0.3.0
      pullPolicy: IfNotPresent

appChannels:
  - channelName: mychannel
    chaincodes:
      - name: mycc
        policy: "OR('Org1MSP.member','Org2MSP.member')"
        version: "1.0"

Test hlf-k8s with your own chaincode

Example with substra/orchestrator

git clone [email protected]:Substra/orchestrator.git

Make your edits to substra/orchestrator.

Then build the image:

docker build -f docker/orchestrator-chaincode/Dockerfile -t substra/orchestrator-chaincode:dev .
docker build -f docker/orchestrator-chaincode-init/Dockerfile -t substra/orchestrator-chaincode-init:dev .

Note: If you use minikube, you need to run eval $(minikube -p minikube docker-env) first

Finally, modify deployment values to use your chaincode image:

For instance with substra/orchestrator-chaincode:my-tag

chaincodes:
- address: network-org-1-peer-1-hlf-k8s-chaincode-mycc.org-1.svc.cluster.local
  name: mycc
  port: 7052
  version: "1.0"
  image:
    repository: substra/orchestrator-chaincode
    tag: my-tag

Add an organization to the system channel

Adding an organization to the system channel allows it to adminstrate application channels.

To add organizations to the system channel, enable the orderer and set the systemChannel.organizations value:

hlf-ord:
   enabled: true
systemChannel:
   organizations:
      - org: MyOrg1
        configUrl: peer.org-1.com/config/configOrg.json
      - org: MyOrg2
        configUrl: peer.org-2.com/config/configOrg.json

On peers, expose the /config/ route using the configOperator.ingress key.

Add an organization to the application channel

MAJORITY policy (default)

With the default application channel policty (MAJORITY), peers need to request approval from one another before they can add an organization to the application channel.

This is done by configuring peers like so:

hlf-peer:
   enabled: true

# Add `MyOrg1` and `MyOrg2` to the application channel
appChannels:
- channelName: mychannel
  organizations:
  - org: MyOrg1
    configUrl: peer.org-1.com/config/configOrgWithAnchors.json
  - org: MyOrg2
    configUrl: peer.org-2.com/config/configOrgWithAnchors.json
    [...]
  proposalOrganizations:
  - org: MyOrg1
    proposalServerUrl: peer.org-1.com/mychannel/proposal/
  - org: MyOrg2
    proposalServerUrl: peer.org-2.com/mychannel/proposal/
    [...]
  # Expose this peer's /mychannel/proposal route
  ingress:
    enabled: true
    hosts:
    - { host: peer.org-1, paths: ["/mychannel/proposal"] }

# Expose this peer's /config route
configOperator:
  ingress:
    enabled: true
    hosts:
    - { host: peer.org-1, paths: ["/config"] }

A majority of peers need to be configured with the above

Other policy (e.g. ANY policy)

The default Hyperledger Fabric application channel policy is MAJORITY. This means a node can only be added to the application channel if a majority of the peers already present in the channel agree.

Use the appChannel.policy key to override the default application channel policy.

For instance, you can configure the application channel with an ANY policy.

Orderer configuration:

appChannels:
- channelName: mychannel
  channelPolicies: |
     Readers:
           Type: ImplicitMeta
           Rule: "ANY Readers"
     Writers:
           Type: ImplicitMeta
           Rule: "ANY Writers"
     Admins:
           Type: ImplicitMeta
           Rule: "ANY Admins"

With this configuration, any peer is allowed to add all the organizations to the application channel, without requiring approval for the other peers.

Peer confi

Deploy hlf-k8s with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has hlf-k8s on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charthlf-k8s is pinned at v10.2.4 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply