1

I have a working docker based setup - peer(s), orderers and explorer (db & app) which I am aiming to deployed on GCP - Kubernetes.

For the peer(s) and orderer I have used the docker images and created kubernetes yaml file with (StatefulSet, Service, NodePort and Ingress) to deploy on Kubernetes.

For Explorer I have the below docker-compose file which depends on my local connection-profile and crypto files.

I am struggling to deploy explorer on kubernetes and looking for advice on the approach

  1. I have tried to convert docker-compose using Kompose - but face issues while translating network and health-check tags.

  2. I have tried to create a single docker-image (Dockerfile - multiple FROM tags) from hyperledger/explorer-db:latest and hyperledger/explorer:latest but again specifying network becomes an issue.

Any suggestions or examples on how Explorer can be deployed in the cluster ??

Thanks

Explorer Docker Compose

version: '2.1'

volumes:
  pgdata:
  walletstore:

networks:
  mynetwork.com:
    external:
      name: my-netywork

services:

  explorerdb.mynetwork.com:
    image: hyperledger/explorer-db:latest
    container_name: explorerdb.mynetwork.com
    hostname: explorerdb.mynetwork.com
    environment:
      - DATABASE_DATABASE=fabricexplorer
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWORD=password
    healthcheck:
      test: "pg_isready -h localhost -p 5432 -q -U postgres"
      interval: 30s
      timeout: 10s
      retries: 5
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - mynetwork.com

  explorer.mynetwork.com:
    image: hyperledger/explorer:latest
    container_name: explorer.mynetwork.com
    hostname: explorer.mynetwork.com
    environment:
      - DATABASE_HOST=explorerdb.mynetwork.com
      - DATABASE_DATABASE=fabricexplorer
      - DATABASE_USERNAME=hppoc
      - DATABASE_PASSWD=password
      - LOG_LEVEL_APP=info
      - LOG_LEVEL_DB=info
      - LOG_LEVEL_CONSOLE=debug
      - LOG_CONSOLE_STDOUT=true
      - DISCOVERY_AS_LOCALHOST=false
    volumes:
      - ./config.json:/opt/explorer/app/platform/fabric/config.json
      - ./connection-profile:/opt/explorer/app/platform/fabric/connection-profile
      - ../config/crypto-config:/tmp/crypto
      - walletstore:/opt/explorer/wallet
    ports:
      - 8080:8080
    depends_on:
      explorerdb.mynetwork.com:
        condition: service_healthy
    networks:
      - mynetwork.com

Explorer Dockerfile - multiple froms

# Updated to Fabric 2.x
#1. Docker file for setting up the Orderer
# FROM hyperledger/fabric-orderer:1.4.2
FROM hyperledger/explorer-db:latest


ENV DATABASE_DATABASE=fabricexplorer
ENV DATABASE_USERNAME=hppoc
ENV DATABASE_PASSWORD=password

FROM hyperledger/explorer:latest


COPY ./config/explorer/. /opt/explorer/
COPY ./config/crypto-config/. /tmp/crypto

ENV DATABASE_HOST=explorerdb.xxx.com
ENV DATABASE_DATABASE=fabricexplorer
ENV DATABASE_USERNAME=hppoc
ENV DATABASE_PASSWD=password
ENV LOG_LEVEL_APP=info
ENV LOG_LEVEL_DB=info
ENV LOG_LEVEL_CONSOLE=debug
ENV LOG_CONSOLE_STDOUT=true
ENV DISCOVERY_AS_LOCALHOST=false

ENV DISCOVERY_AS_LOCALHOST=false
# ENV EXPLORER_APP_ROOT=${EXPLORER_APP_ROOT:-dist}
# ENV ${EXPLORER_APP_ROOT}/main.js name - hyperledger-explorer
ENTRYPOINT ["tail", "-f", "/dev/null"]
maxkart
  • 619
  • 5
  • 21

1 Answers1

0

There are 2 groups of required steps for this setup. One I tested is:

1.Create a K8s cluster

2.Connect your cluster with the cloud shell

3.Clone this repository

git clone https://github.com/acloudfan/HLF-K8s-Cloud.git

4.Setup the storage class

cd HLF-K8s-Cloud/gcp kubectl apply -f . This will setup the storage class

5.Launch the Acme Orderer

cd .. kubectl apply -f ./k8s-acme-orderer.yaml Check the logs for 'acme-orderer-0' to ensure there is no error

6.Launch the Acme Peer

kubectl apply -f ./k8s-acme-peer.yaml Check the logs for 'acme-peer-0' to ensure there is no error

7.Setup the Channel & Join acme peer to it.

kubectl exec -it acme-peer-0 /bin/bash ./submit-channel-create.sh
 
./join-channel.sh

Ensure that peer has joined the channel

peer channel list
 
exit

8.Launch the budget Peer and join it to the channel

kubectl apply -f ./k8s-budget-peer.yaml Wait for the container to launch & check the logs for errors



kubectl exec -it budget-peer-0 /bin/bash ./fetch-channel-block.sh ./join-channel.sh

Ensure that peer has joined the channel

peer channel list
 
exit ** At this point your K8s Fabric Network is up **

Validate the network

1.Install & Instantiate the test chaincode

kubectl exec -it acme-peer-0 /bin/bash



./cc-test.sh install ./cc-test.sh instantiate

2.Invoke | Query the chaincode to see the changes in values of a/b

./cc-test.sh query ./cc-test.sh invoke

3.Check the values inside the Budget peer

kubectl exec -it acme-peer-0 /bin/bash



./cc-test.sh install



./cc-test.sh query The query should return the same values as you see in acme-peer Execute invoke/query in both peers to validate

Plus, you can visit the following threads to see option 2 and more references on the proper steps to set up your environment Production Network with GKE, HLF-K8s-Cloud, Hyperledger Fabric blockchain deployment on Google Kubernetes Engine and hyperledger/fabric-peer.