XenonStack

A Stack Innovator

Post Top Ad

Thursday 16 February 2017

BlockChain App Deployment Using Microservices With Kubernetes


What is a BlockChain?


BlockChain is a distributed database that maintains a continuously-growing list of ordered records called blocks. This technology underlying Bitcoin and other cryptocurrencies.

It is a public ledger of all Bitcoin transaction. These blocks are added in a chronological order. In order to deploy a blockchain application, you need a distributed Hyperledger blockchain on your choice of infrastructure (on-premise or cloud).

In this article, we will deploy a Hyperledger Fabric cluster using Kubernetes.

Prerequisites


To follow this guide you need a system with working kubernetes cluster on it. We will use Fabric which is an implementation of blockchain technology written in Golang so go version go1.6.2 or above is required.

Before proceeding further let’s have a look on Hyperledger Fabric.

The Hyperledger Project


Hyperledger is an open source project with collaborative effort created to advance blockchain technology.

It helps in cross-industry distributed ledgers which support transaction system, property transaction, and other services.


Hyperledger Fabric


The Fabric is an implementation of blockchain technology. It provides a modular architecture allowing pluggable implementations of the various function.


Setting Hyperledger Cluster on Kubernetes


Hyperledger Kubernetes Replication Controller


We will launch hyperledger on kubernetes as a Replication Controller it will ensure us the high - availability of hyperledger pods.

Create a file named membersrvc-rc.yml.
 
apiVersion: v1
kind: ReplicationController
metadata:
  creationTimestamp: null
  labels:
    service: membersrvc
  name: membersrvc
  namespace: default
spec:
  replicas: 1
  selector:
    service: membersrvc
  template:
    metadata:
      creationTimestamp: null
      labels:
        service: membersrvc
    spec:
      containers:
      - command:
        - membersrvc
        image: hyperledger/fabric-membersrvc
        imagePullPolicy: ""
        name: membersrvc
        ports:
        - containerPort: 7054
        resources: {}
      restartPolicy: Always
      serviceAccountName: ""
      volumes: null
status:
  replicas: 0  

 
In the same way, create another file vp0-rc.yml


apiVersion: v1
kind: ReplicationController
metadata:
  creationTimestamp: null
  labels:
    service: vp0
  name: vp0
  namespace: ${NAMESPACE}
spec:
  replicas: 1
  selector:
    service: vp0
  template:
    metadata:
      creationTimestamp: null
      labels:
        service: vp0
    spec:
      containers:
      - command:
        - sh
        - -c
        - sleep 5; peer node start --peer-chaincodedev
        env:
        - name: CORE_PEER_ADDRESSAUTODETECT
          value: "true"
        - name: CORE_VM_ENDPOINT
          value: unix:///var/run/docker.sock
        - name: CORE_LOGGING_LEVEL
          value: DEBUG
        - name: CORE_PEER_ID
          value: vp0
        - name: CORE_PEER_PKI_ECA_PADDR
          value: membersrvc:7054
        - name: CORE_PEER_PKI_TCA_PADDR
          value: membersrvc:7054
        - name: CORE_PEER_PKI_TLSCA_PADDR
          value: membersrvc:7054
        - name: CORE_SECURITY_ENABLED
          value: "false"
        - name: CORE_SECURITY_ENROLLID
          value: test_vp0
        - name: CORE_SECURITY_ENROLLSECRET
          value: MwYpmSRjupbT
        image: hyperledger/fabric-peer
        imagePullPolicy: ""
        name: vp0
        ports:
        - containerPort: 7050
        - containerPort: 7051
        - containerPort: 7053
        resources: {}
      restartPolicy: Always
      serviceAccountName: ""
      volumes: null
status:
  replicas: 0


That’s enough with replication controller. Now our next target is to deploy services for the Replication Controller.

Create a file called membersrvc-srv.yml


apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  name: membersrvc
  namespace: default
spec:
  ports:
  - name: ""
    nodePort: 0
    port: 7054
    protocol: ""
    targetPort: 0
  selector:
    service: membersrvc
status:
  loadBalancer: {}


Create another file vp0-srv.yml


apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  name: vp0
  namespace: default
spec:
  type: NodePort
  ports:
  - name: "port1"
    port: 7050
    protocol: ""
    targetPort: 0
  - name: "port2"
    nodePort: 0
    port: 7051
    protocol: ""
    targetPort: 0
  - name: "port3"
    nodePort: 0
    port: 7053
    protocol: ""
    targetPort: 0
  selector:
    service: vp0
status:
  loadBalancer: {}

Running Hyperledger Pods


After creating all the necessary file, next step is to start these rc pods

$ kubectl create -f membersrvc-rc.yml

$ kubectl create -f vp0-rc.yml




blockchain apps deployment using microservices with kubernetes







Continue Reading the Full Article At - XenonStack.com/Blog

No comments:

Post a Comment