All Projects → kfsoftware → hlf-operator

kfsoftware / hlf-operator

Licence: Apache-2.0 license
Hyperledger Fabric Kubernetes operator - Hyperledger Fabric operator for Kubernetes (v2.2+)

Programming Languages

go
31211 projects - #10 most used programming language
java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
Mustache
554 projects
typescript
32286 projects
Makefile
30231 projects

Projects that are alternatives of or similar to hlf-operator

hyperledger-fabric-sdk-php
Client SDK for Hyperledger Fabric for use in PHP applications
Stars: ✭ 40 (-64.29%)
Mutual labels:  fabric, hyperledger, hyperledger-fabric
hlfabric-k8scc
Chaincode builder and launcher for Hyperledger Fabric on Kubernetes
Stars: ✭ 21 (-81.25%)
Mutual labels:  hyperledger, hyperledger-fabric, chaincode
Fabric Starter
Starter Application and Deployment Scripts for Hyperledger Fabric
Stars: ✭ 202 (+80.36%)
Mutual labels:  fabric, hyperledger, hyperledger-fabric
byzantine-browser
KHS Blockchain Browser
Stars: ✭ 19 (-83.04%)
Mutual labels:  fabric, hyperledger, chaincode
bdk
Streamlined blockchain deployment kit for Hyperledger Fabric.
Stars: ✭ 43 (-61.61%)
Mutual labels:  fabric, hyperledger, hyperledger-fabric
mastering-blockchain
blockchain basis,logic,usage
Stars: ✭ 29 (-74.11%)
Mutual labels:  hyperledger, hyperledger-fabric
HealthLedger
Application for tracking Organs donations in hospitals and minimizing the scope of Organ trafficking using Blockchain (Hyperledger) technology.
Stars: ✭ 29 (-74.11%)
Mutual labels:  hyperledger, hyperledger-fabric
docker-hyperledger-fabric-peer
Docker image for Hyperledger Fabric Peer
Stars: ✭ 25 (-77.68%)
Mutual labels:  hyperledger, hyperledger-fabric
Probe
Probe is a web GUI application with for Hyperledger Fabric maintainer, user, research to find the best block config logic for specific chain-code.
Stars: ✭ 29 (-74.11%)
Mutual labels:  fabric, hyperledger-fabric
fabric-token-sdk
The Fabric Token SDK is a set of API and services that lets developers create token-based distributed application on Hyperledger Fabric.
Stars: ✭ 63 (-43.75%)
Mutual labels:  hyperledger, hyperledger-fabric
Contracts
All WiBX blockchain chain code
Stars: ✭ 20 (-82.14%)
Mutual labels:  hyperledger, chaincode
hyperledger-fabric-graphql-boilerplate
Hyperledger Fabric GraphQL Boilerplate
Stars: ✭ 44 (-60.71%)
Mutual labels:  fabric, hyperledger
readme
The Blockchain Bible,a collections for blockchain tech,bitcoin,ethereum,crypto currencies,cryptography,decentralized solutions,business scenarios,hyperledger tech,meetups,区块链,数字货币,加密货币,比特币,以太坊,密码学,去中心化,超级账本
Stars: ✭ 46 (-58.93%)
Mutual labels:  hyperledger, hyperledger-fabric
fabric
这是基于fabric 1.4.1 版本国密改造项目
Stars: ✭ 62 (-44.64%)
Mutual labels:  fabric, hyperledger
fabric-iot
fabric-iot is a Blockchain Based Decentralized Access Control System in IoT
Stars: ✭ 50 (-55.36%)
Mutual labels:  hyperledger-fabric, chaincode
hurley
The development environment toolset for blockchain projects
Stars: ✭ 79 (-29.46%)
Mutual labels:  hyperledger, hyperledger-fabric
fablo
Fablo is a simple tool to generate the Hyperledger Fabric blockchain network and run it on Docker. It supports RAFT and solo consensus protocols, multiple organizations and channels, chaincode installation and upgrade.
Stars: ✭ 121 (+8.04%)
Mutual labels:  hyperledger, hyperledger-fabric
fabric-smart-client
The Fabric Smart Client is a new Fabric Client that lets you focus on the business processes and simplifies the development of Fabric-based distributed application.
Stars: ✭ 40 (-64.29%)
Mutual labels:  fabric, hyperledger-fabric
OpenTender
E-portal for government tender process using Hyperledger (Blockchain) technology.
Stars: ✭ 18 (-83.93%)
Mutual labels:  hyperledger, hyperledger-fabric
blockchain-insurance
Blockchain Car Insurance with Smart Contracts on Hyperledger
Stars: ✭ 72 (-35.71%)
Mutual labels:  hyperledger, chaincode
id title
getting-started
Getting started

Hyperledger Fabric Operator

Features

  • Create certificates authorities (CA)
  • Create peers
  • Create ordering services
  • Create resources without manual provisioning of cryptographic material
  • Domain routing with SNI using Istio
  • Run chaincode as external chaincode in Kubernetes
  • Support Hyperledger Fabric 2.3+
  • Managed genesis for Ordering services
  • E2E testing including the execution of chaincodes in KIND
  • Renewal of certificates

Stay Up-to-Date

hlf-operator is currently in stable. Watch releases of this repository to be notified for future updates:

hlf-operator-star-github

Discord

For discussions and questions, please join the Hyperledger Foundation Discord:

https://discord.com/invite/hyperledger

Channel is located under LABS, named hlf-operator.

Tutorial Videos

Step by step video tutorials to setup hlf-opertor in kubernetes

Hyperledger Fabric on Kubernetes

Hyperledger Meetup

You can watch this video in order to see how to use it to deploy your own network:

Hyperledger Fabric on Kubernetes

Sponsor

kfs logo If you want to design and deploy a secure Blockchain network based on the latest version of Hyperledger Fabric, feel free to contact [email protected] or visit https://kfs.es/blockchain

Getting started

Requirements

  • Fabric CA client
  • YQ binary to replace values in YAML (for the getting started)
  • KubeCTL
  • Kubernetes 1.15+
  • Istio

Install Istio

kubectl apply -f ./hack/istio-operator/crds/*
helm template ./hack/istio-operator/ \
  --set hub=docker.io/istio \
  --set tag=1.8.0 \
  --set operatorNamespace=istio-operator \
  --set watchedNamespaces=istio-system | kubectl apply -f -

kubectl create ns istio-system
kubectl apply -n istio-system -f ./hack/istio-operator.yaml

Installing the operator

Add the helm chartrepository:

helm repo add kfs https://kfsoftware.github.io/hlf-helm-charts --force-update 
helm install hlf-operator --version=1.6.0 kfs/hlf-operator

Installing the Kubectl HLF Plugin

To install the Kubectl HLF Plugin, run the following command:

kubectl krew install hlf

To update the Kubectl HLF Plugin to the latest version, run the following command:

 kubectl krew upgrade hlf 

Deploy a Peer Organization

Setup versions

export PEER_IMAGE=hyperledger/fabric-peer
export PEER_VERSION=2.4.3

export ORDERER_IMAGE=hyperledger/fabric-orderer
export ORDERER_VERSION=2.4.3

Deploying a Certificate Authority

kubectl hlf ca create --storage-class=standard --capacity=2Gi --name=org1-ca \
    --enroll-id=enroll --enroll-pw=enrollpw  
kubectl wait --timeout=180s --for=condition=Running fabriccas.hlf.kungfusoftware.es --all

# register user for the peers
kubectl hlf ca register --name=org1-ca --user=peer --secret=peerpw --type=peer \
 --enroll-id enroll --enroll-secret=enrollpw --mspid Org1MSP

Deploying a peer

kubectl hlf peer create --statedb=couchdb --image=$PEER_IMAGE --version=$PEER_VERSION --storage-class=standard --enroll-id=peer --mspid=Org1MSP \
        --enroll-pw=peerpw --capacity=5Gi --name=org1-peer0 --ca-name=org1-ca.default
kubectl wait --timeout=180s --for=condition=Running fabricpeers.hlf.kungfusoftware.es --all

Deploying an Ordering Service

Deploying a certificate authority

kubectl hlf ca create --storage-class=standard --capacity=2Gi --name=ord-ca \
    --enroll-id=enroll --enroll-pw=enrollpw
kubectl wait --timeout=180s --for=condition=Running fabriccas.hlf.kungfusoftware.es --all
kubectl hlf ca register --name=ord-ca --user=orderer --secret=ordererpw \
    --type=orderer --enroll-id enroll --enroll-secret=enrollpw --mspid=OrdererMSP

Deploying the Orderer nodes node

kubectl hlf ordnode create --image=$ORDERER_IMAGE --version=$ORDERER_VERSION \
    --storage-class=standard --enroll-id=orderer --mspid=OrdererMSP \
    --enroll-pw=ordererpw --capacity=2Gi --name=ord-node1 --ca-name=ord-ca.default
kubectl wait --timeout=180s --for=condition=Running fabricorderernodes.hlf.kungfusoftware.es --all

Preparing a connection string for the ordering service

kubectl hlf inspect --output ordservice.yaml -o OrdererMSP
kubectl hlf ca register --name=ord-ca --user=admin --secret=adminpw \
    --type=admin --enroll-id enroll --enroll-secret=enrollpw --mspid=OrdererMSP

kubectl hlf ca enroll --name=ord-ca --user=admin --secret=adminpw --mspid OrdererMSP \
        --ca-name ca  --output admin-ordservice.yaml 
## add user from admin-ordservice.yaml to ordservice.yaml
kubectl hlf utils adduser --userPath=admin-ordservice.yaml --config=ordservice.yaml --username=admin --mspid=OrdererMSP

Create a channel

kubectl hlf channel generate --output=demo.block --name=demo --organizations Org1MSP --ordererOrganizations OrdererMSP

# enroll using the TLS CA
kubectl hlf ca enroll --name=ord-ca --namespace=default --user=admin --secret=adminpw --mspid OrdererMSP \
        --ca-name tlsca  --output admin-tls-ordservice.yaml 

kubectl hlf ordnode join --block=demo.block --name=ord-node1 --namespace=default --identity=admin-tls-ordservice.yaml

Preparing a connection string for the peer

kubectl hlf ca register --name=org1-ca --user=admin --secret=adminpw --type=admin \
 --enroll-id enroll --enroll-secret=enrollpw --mspid Org1MSP  

kubectl hlf ca enroll --name=org1-ca --user=admin --secret=adminpw --mspid Org1MSP \
        --ca-name ca  --output peer-org1.yaml

kubectl hlf inspect --output org1.yaml -o Org1MSP -o OrdererMSP

## add user key and cert to org1.yaml from admin-ordservice.yaml
kubectl hlf utils adduser --userPath=peer-org1.yaml --config=org1.yaml --username=admin --mspid=Org1MSP

Join channel

kubectl hlf channel join --name=demo --config=org1.yaml \
    --user=admin -p=org1-peer0.default

Inspect the channel

kubectl hlf channel inspect --channel=demo --config=org1.yaml \
    --user=admin -p=org1-peer0.default > demo.json

Add anchor peer

kubectl hlf channel addanchorpeer --channel=demo --config=org1.yaml \
    --user=admin --peer=org1-peer0.default 

See ledger height

In case of error, you may need to add the following to the org1.yaml configuration file:

channels:
  _default:
    orderers:
      - ord-node1.default
    peers:
      "org1-peer0.default":
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
kubectl hlf channel top --channel=demo --config=org1.yaml \
    --user=admin -p=org1-peer0.default

Install a chaincode

# remove the code.tar.gz asset-transfer-basic-external.tgz if they exist
rm code.tar.gz asset-transfer-basic-external.tgz
export CHAINCODE_NAME=asset
export CHAINCODE_LABEL=asset
cat << METADATA-EOF > "metadata.json"
{
    "type": "ccaas",
    "label": "${CHAINCODE_LABEL}"
}
METADATA-EOF

cat > "connection.json" <<CONN_EOF
{
  "address": "${CHAINCODE_NAME}:7052",
  "dial_timeout": "10s",
  "tls_required": false
}
CONN_EOF

tar cfz code.tar.gz connection.json
tar cfz asset-transfer-basic-external.tgz metadata.json code.tar.gz
export PACKAGE_ID=$(kubectl hlf chaincode calculatepackageid --path=asset-transfer-basic-external.tgz --language=node --label=$CHAINCODE_LABEL)
echo "PACKAGE_ID=$PACKAGE_ID"

kubectl hlf chaincode install --path=./asset-transfer-basic-external.tgz \
    --config=org1.yaml --language=golang --label=$CHAINCODE_LABEL --user=admin --peer=org1-peer0.default

# this can take 3-4 minutes

Deploy chaincode

The following command will create or update the CRD based on the packageID, chaincode name and image.

kubectl hlf externalchaincode sync --image=kfsoftware/chaincode-external:latest \
    --name=$CHAINCODE_NAME \
    --namespace=default \
    --package-id=$PACKAGE_ID \
    --tls-required=false \
    --replicas=1

Query chaincodes installed

kubectl hlf chaincode queryinstalled --config=org1.yaml --user=admin --peer=org1-peer0.default

Approve chaincode

export SEQUENCE=1
export VERSION="1.0"
kubectl hlf chaincode approveformyorg --config=org1.yaml --user=admin --peer=org1-peer0.default \
    --package-id=$PACKAGE_ID \
    --version "$VERSION" --sequence "$SEQUENCE" --name=asset \
    --policy="OR('Org1MSP.member')" --channel=demo

Commit chaincode

kubectl hlf chaincode commit --config=org1.yaml --user=admin --mspid=Org1MSP \
    --version "$VERSION" --sequence "$SEQUENCE" --name=asset \
    --policy="OR('Org1MSP.member')" --channel=demo

Invoke a transaction in the ledger

kubectl hlf chaincode invoke --config=org1.yaml \
    --user=admin --peer=org1-peer0.default \
    --chaincode=asset --channel=demo \
    --fcn=initLedger -a '[]'

Query the ledger

kubectl hlf chaincode query --config=org1.yaml \
    --user=admin --peer=org1-peer0.default \
    --chaincode=asset --channel=demo \
    --fcn=GetAllAssets -a '[]'

At this point, you should have:

  • Ordering service with 1 nodes and a CA
  • Peer organization with a peer and a CA
  • A channel demo
  • A chaincode install in peer0
  • A chaincode approved and committed

If something went wrong or didn't work, please, open an issue.

Cleanup the environment

kubectl delete fabricorderernodes.hlf.kungfusoftware.es --all-namespaces --all
kubectl delete fabricpeers.hlf.kungfusoftware.es --all-namespaces --all
kubectl delete fabriccas.hlf.kungfusoftware.es --all-namespaces --all
kubectl delete fabricchaincode.hlf.kungfusoftware.es --all-namespaces --all

Troubleshooting

Chaincode installation/build error

Chaincode installation/build can fail due to unsupported local kubertenes version such as minikube.

$ kubectl hlf chaincode install --path=./fixtures/chaincodes/fabcar/go \
        --config=org1.yaml --language=golang --label=fabcar --user=admin --peer=org1-peer0.default
        
Error: Transaction processing for endorser [192.168.49.2:31278]: Chaincode status Code: (500) UNKNOWN. 
Description: failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: 
external builder failed: external builder failed to build: external builder 'my-golang-builder' failed:
exit status 1

If your purpose is to test the hlf-operator please consider to switch to kind that is tested and supported.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].