All Projects → postfinance → hlfabric-k8scc

postfinance / hlfabric-k8scc

Licence: MIT license
Chaincode builder and launcher for Hyperledger Fabric on Kubernetes

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to hlfabric-k8scc

hlf-operator
Hyperledger Fabric Kubernetes operator - Hyperledger Fabric operator for Kubernetes (v2.2+)
Stars: ✭ 112 (+433.33%)
Mutual labels:  hyperledger, hyperledger-fabric, chaincode
heroes-service-network
Short tutorial to build a blockchain network with Hyperledger Fabric
Stars: ✭ 22 (+4.76%)
Mutual labels:  hyperledger, hyperledger-fabric
fabric-iot
fabric-iot is a Blockchain Based Decentralized Access Control System in IoT
Stars: ✭ 50 (+138.1%)
Mutual labels:  hyperledger-fabric, chaincode
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 (+200%)
Mutual labels:  hyperledger, hyperledger-fabric
mastering-blockchain
blockchain basis,logic,usage
Stars: ✭ 29 (+38.1%)
Mutual labels:  hyperledger, hyperledger-fabric
Pivt
Helm charts for running and operating Hyperledger Fabric in Kubernetes. Previously hosted at https://github.com/APGGroeiFabriek/PIVT.
Stars: ✭ 159 (+657.14%)
Mutual labels:  hyperledger, hyperledger-fabric
Heroes Service
Short tutorial to build a blockchain application in Go with Hyperledger Fabric
Stars: ✭ 248 (+1080.95%)
Mutual labels:  hyperledger, hyperledger-fabric
byzantine-browser
KHS Blockchain Browser
Stars: ✭ 19 (-9.52%)
Mutual labels:  hyperledger, chaincode
Awesome Hyperledger Fabric
A curated list of resources for creating applications with hyperledger fabric
Stars: ✭ 349 (+1561.9%)
Mutual labels:  hyperledger, hyperledger-fabric
Fabric Sdk Go
Stars: ✭ 712 (+3290.48%)
Mutual labels:  hyperledger, hyperledger-fabric
Fabric Gm Wiki
Fabric国密项目 wiki
Stars: ✭ 79 (+276.19%)
Mutual labels:  hyperledger, hyperledger-fabric
bdk
Streamlined blockchain deployment kit for Hyperledger Fabric.
Stars: ✭ 43 (+104.76%)
Mutual labels:  hyperledger, hyperledger-fabric
hlf-sdk-go
Hyperledger Fabric Golang SDK
Stars: ✭ 37 (+76.19%)
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 (+476.19%)
Mutual labels:  hyperledger, hyperledger-fabric
Fabric Starter
Starter Application and Deployment Scripts for Hyperledger Fabric
Stars: ✭ 202 (+861.9%)
Mutual labels:  hyperledger, hyperledger-fabric
hyperledger-fabric-sdk-php
Client SDK for Hyperledger Fabric for use in PHP applications
Stars: ✭ 40 (+90.48%)
Mutual labels:  hyperledger, hyperledger-fabric
hurley
The development environment toolset for blockchain projects
Stars: ✭ 79 (+276.19%)
Mutual labels:  hyperledger, hyperledger-fabric
blockchain-insurance
Blockchain Car Insurance with Smart Contracts on Hyperledger
Stars: ✭ 72 (+242.86%)
Mutual labels:  hyperledger, chaincode
fabric-composer-engine-supplychain
Hyperledger Fabric & Composer example that models a consortium of car engine manufacturers, merchants and customers.
Stars: ✭ 19 (-9.52%)
Mutual labels:  hyperledger, hyperledger-fabric
Blockchainbooks.github.io
Blockchain Books
Stars: ✭ 139 (+561.9%)
Mutual labels:  hyperledger, hyperledger-fabric

hlfabric-k8scc

Test k8scc on Kubernetes

Chaincode launcher and builder for Hyperledger Fabric on Kubernetes

Features

This project implements an external chaincode launcher and builder for Hyperledger Fabric. It talks directly to the Kubernetes API and doesn't depend on Docker which enables you to deploy a Hyperledger Fabric Peer on Kubernetes without exposing the Docker socket and therefore improve security and portability.

The following points have been addressed:

  • Chaincode build runs separated from the peer
  • Chaincode is launched separated from the peer
  • The build and launch of chaincode is compatible with the default/internal system
  • The chaincode must be usable without changes
  • The used images for build and launch of the chaincode can be the same as in the internal system
  • Kubernetes security mechanisms can be enforced (network policies, host isolation, etc.)
  • There is no dependency on the Kubernetes CRI implementation (like Docker)
  • There is no need for priviledged pods
  • stdout and stderr of the chaincode is forwarded to the peer
  • The peer notices when a chaincode fails

Usage

Requirements:

  • The peer runs as a pod under a Kubernetes ServiceAccount that can manipulate pods
  • The peer uses a PersistentVolume provided by a PersistentVolumeClaim, which is used to exchange data between the peer, builder and launcher pods

The easiest way to use this project is by using the postfinance/hlfabric-k8scc Docker image. It's based on the Hyperledger Fabric Peer image and extended with a default configuration.

When you have your peer running on Kubernetes, you need to ensure that the rbac are set and that the peer pod runs as a service account matching the rules. The following configuration must be done for the peer:

spec:
  template:
    spec:
      serviceAccountName: peer                             # run peer as service account
      containers:
      - image: postfinance/hlfabric-k8scc:2.2.1-k8scc0.0.8 # use an appropriate image and tag
        - name: K8SCC_CFGFILE
          value: "/opt/k8scc/k8scc.yaml"                   # this points to the default configuration file
        volumeMounts:
        - mountPath: /var/lib/k8scc/transfer/              # here we mount our transfer PV
          name: transfer-pv
      volumes:
      - name: transfer-pv
        persistentVolumeClaim:
          claimName: k8scc-transfer-pv                     # this is our default claim name for transfer PVs

You can have a look in the example directory for a more complete example. If you want to customize the images or the resources, you need to use an own k8scc.yaml configuration file.

And if you have an own core.yaml, you need to configure the launcher. Have a look at this patch. It is not possible to inject this data structure using environment variables.

Development

Tags

The version tags are defined as follows This allows to create (hotfix) branches for different peer versions.

  • {{ peer version }}-k8scc{{ k8scc version }}: recommended tag scheme for production use
  • v{{ k8scc version }}: tag scheme used internally for k8scc development

Examples:

  • 2.2.1-k8scc0.0.8: Peer v2.2.1, k8scc v0.0.8
  • v0.0.8: k8scc v0.0.8, peer at undefined version

Releasing

If you want to release a new version of k8scc, do the following:

  1. Set the desired peer version in Dockerfile
  2. Run prepare_release
  3. Commit changes of updated dependencies, if any
  4. Set the tags generated by prepare_release to the latest commit

Steps

This software implements the four parts of an external chaincode launcher and builder: detect, build, release, run.

Step detect

The step detect just checks the metadata.json if the defined platform (e.g. golang) is available in Hyperledger Fabric and if an appropriate image is configured in k8scc.yaml

Step build

The step build is responsible for building the chaincode while ensuring compatibility of the chaincode with the internal builder process.

The preparation:

  1. Parse metadata.json and check if the plattform (e.g. golang) is supported
  2. Create a temporary directory on the transfer volume
  3. Inside this temporary directory, copy the provided chaincode source and create an empty directory for the build output

Next, a builder pod is created and has the following properties:

  • The name is {{ peer pod name}}-ccbuild-{{ short hash }}
  • It has the temporary subdirectories of the transfer PV mounted
  • The command is the same as the one used by Hyperledger Fabric on its internal builder

The created pod is watched until it finishes either successfully or not. Afterwards this procedure is executed:

  1. Write stdout and stderr of the builder pod to the peer log
  2. Only if the build failed: Remove all garbage (pod + temporary directory) and exit
  3. Copy output data from the temporary directory to the output directory on the peer
  4. Copy data from the META-INF in the source directory to the output directory on the peer
  5. Write build information to the output directory, in order to use the same image for the launch as for the build
  6. Cleanup pod and remove the temporary directory

Step release

The step release just copies the data from META-INF to the output directory provided by the peer

Step run

The step run responsible for launching the chaincode while ensuring compatibility of the chaincode with the internal launcher process.

The preparation:

  1. Parse build information to extract the used image
  2. Create a temporary directory on the transfer volume
  3. Inside this temporary directory, copy the build output and the artifacts like certificates extracted from chaincode.json

Next, a launcher pod is created and has the following properties:

  • The name is {{ peer pod name}}-cc-{{ chaincode label }}-{{ short hash }}
  • It has the temporary subdirectories of the transfer PV mounted
  • The platform/language dependant command starts the chaincode

The created pod is watched until it exits. Afterwards this procedure is executed:

  1. Write stdout and stderr of the launcher pod to the peer log
  2. Remove all garbage (pod + temporary directory)
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].