External chaincode as a service
Fabric 2.0 enabled the ability to deploy chaincode as a service. This is a chaincode that runs on a remote machine, container, or baremetal, and the peer will connect to it.
HLF-operator supports the installation of chaincode as a service, using the ccaas
external builder that Hyperledger Fabric supports out-of-the-box since the version 2.4.1
#
Step 1: Prepare a Docker image for the chaincodeTo deploy the chaincode in Kubernetes, we need to prepare a Docker image that has the chaincode in it.
You can use the following code as a baseline: https://github.com/hyperledger/fabric-samples/tree/main/chaincode/fabcar/external
It contains a Dockerfile
and a fabcar.go
, if you build that folder:
And then push it to Docker Hub:
You will be able to deploy the chaincode in the step 3
#
Step 2: Install the chaincodeIn this step we will install the chaincode using the ccaas
external builder, telling the address of the chaincode service where the chaincode will be deployed.
#
Step 3: Deploy the chaincodeIn this last step, we will deploy the chaincode using the ccaas
external builder, specifying the name of the chaincode, which must be the same as we specified in the previous step.
And we will also specify the image which you have pushed in the first step.