diff --git a/sample-network/README.md b/sample-network/README.md index 5e5713c1..e1e7b207 100644 --- a/sample-network/README.md +++ b/sample-network/README.md @@ -200,8 +200,17 @@ or ```shell network unkind ``` - - +## Hyperledger explorer +To setup explorer follow below steps +```shell +cd explorer/ +source explorer.sh +``` +(it will launch explorer at https://explorer.localho.st/) +```shell +source clean.sh +``` +(it will remove the explorer) ## Appendix: Operations Console Launch the [Fabric Operations Console](https://github.com/hyperledger-labs/fabric-operations-console): diff --git a/sample-network/explorer/clean.sh b/sample-network/explorer/clean.sh new file mode 100644 index 00000000..76a405fd --- /dev/null +++ b/sample-network/explorer/clean.sh @@ -0,0 +1,9 @@ +#!/bin/bash +export NS=test-network +kubectl -n $NS delete deployment explorer-db explorer --ignore-not-found=true +kubectl -n $NS delete service explorerdb-service explorer --ignore-not-found=true +kubectl -n $NS delete configmap explorer-config --ignore-not-found=true +kubectl -n $NS delete secret my-secret --ignore-not-found=true +kubectl -n $NS delete ingress explorer --ignore-not-found=true +kubectl -n $NS delete pvc mypvc --ignore-not-found=true +kubectl delete pv mypv --ignore-not-found=true \ No newline at end of file diff --git a/sample-network/explorer/configmap.yaml b/sample-network/explorer/configmap.yaml new file mode 100644 index 00000000..9245dc0e --- /dev/null +++ b/sample-network/explorer/configmap.yaml @@ -0,0 +1,76 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: explorer-config +data: + network.json: |- + { + "name": "test-network", + "version": "1.0.0", + "client": { + "tlsEnable": true, + "adminCredential": { + "id": "exploreradmin", + "password": "exploreradminpw" + }, + "enableAuthentication": true, + "organization": "Org1MSP", + "connection": { + "timeout": { + "peer": { + "endorser": "300" + }, + "orderer": "300" + } + } + }, + "channels": { + "mychannel": { + "peers": { + "peer0-org1": {} + }, + "connection": { + "timeout": { + "peer": { + "endorser": "6000", + "eventHub": "6000", + "eventReg": "6000" + } + } + } + } + }, + "organizations": { + "Org1MSP": { + "mspid": "Org1MSP", + "adminPrivateKey": { + "path": "/organizations/key.pem" + }, + "peers": [ + "peer0-org1" + ], + "signedCert": { + "path": "/organizations/cert.pem" + } + } + }, + "peers": { + "peer0-org1": { + "tlsCACerts": { + "path": "/organizations/tlsca-signcert.pem" + }, + "url": "grpcs://test-network-org1-peer1-peer.localho.st:443" + } + } + } + + config.json: |- + { + "network-configs": { + "test-network": { + "name": "test-network", + "profile": "./test-network.json" + } + }, + "license": "Apache-2.0" + } diff --git a/sample-network/explorer/explorer.sh b/sample-network/explorer/explorer.sh new file mode 100644 index 00000000..5537cc97 --- /dev/null +++ b/sample-network/explorer/explorer.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# kubectl create namespace explorer +kubectl create secret generic explorer-secret --from-file=key.pem=${PWD}/../temp/enrollments/org1/users/org1admin/msp/keystore/key.pem \ +--from-file=cert.pem=${PWD}/../temp/enrollments/org1/users/org1admin/msp/signcerts/cert.pem \ + --from-file=tlsca-signcert.pem=${PWD}/../temp/channel-msp/peerOrganizations/org1/msp/tlscacerts/tlsca-signcert.pem -n test-network +kubectl apply -f . -n test-network diff --git a/sample-network/explorer/explorer.yaml b/sample-network/explorer/explorer.yaml new file mode 100644 index 00000000..8bf3bbda --- /dev/null +++ b/sample-network/explorer/explorer.yaml @@ -0,0 +1,104 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: explorer +spec: + selector: + matchLabels: + app: explorer + template: + metadata: + labels: + app: explorer + spec: + volumes: + - name: fabricfiles + persistentVolumeClaim: + claimName: mypvc + - name: explorer-config + configMap: + name: explorer-config + items: + - key: config.json + path: config.json + - key: network.json + path: network.json + - name: secret-volume + secret: + secretName: explorer-secret + containers: + - name: explorer + image: hyperledger/explorer:latest + env: + - name: DATABASE_HOST + value: "explorerdb-service" + - name: DATABASE_DATABASE + value: "fabricexplorer" + - name: DATABASE_USERNAME + value: "hppoc" + - name: DATABASE_PASSWD + value: "password" + - name: LOG_LEVEL_APP + value: "debug" + - name: LOG_LEVEL_DB + value: "debug" + - name: LOG_LEVEL_CONSOLE + value: "info" + - name: LOG_CONSOLE_STDOUT + value: "true" + - name: DISCOVERY_AS_LOCALHOST + value: "false" + resources: + limits: + memory: "528Mi" + cpu: "400m" + ports: + - containerPort: 8080 + volumeMounts: + # - mountPath: /organizations + # name: fabricfiles + # subPath: organizations + - mountPath: /opt/explorer/app/platform/fabric/config.json + name: explorer-config + subPath: config.json + - mountPath: /opt/explorer/app/platform/fabric/test-network.json + name: explorer-config + subPath: network.json + - name: secret-volume + readOnly: true + mountPath: /organizations + +--- +apiVersion: v1 +kind: Service +metadata: + name: explorer +spec: + selector: + app: explorer + ports: + - port: 80 + targetPort: 8080 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: explorer + annotations: + nginx.ingress.kubernetes.io/proxy-connect-timeout: 60s +spec: + ingressClassName: nginx + rules: + - host: explorer.localho.st + http: + paths: + - backend: + service: + name: explorer + port: + number: 80 + path: / + pathType: ImplementationSpecific + tls: + - hosts: + - explorer.localho.st diff --git a/sample-network/explorer/explorerdb.yaml b/sample-network/explorer/explorerdb.yaml new file mode 100644 index 00000000..67460257 --- /dev/null +++ b/sample-network/explorer/explorerdb.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: explorer-db +spec: + selector: + matchLabels: + app: explorer-db + template: + metadata: + labels: + app: explorer-db + spec: + volumes: + - name: fabricfiles + persistentVolumeClaim: + claimName: mypvc + - name: secret-volume + secret: + secretName: explorer-secret + containers: + - name: explorer-db + image: hyperledger/explorer-db:latest + env: + - name: DATABASE_DATABASE + value: fabricexplorer + - name: DATABASE_USERNAME + value: hppoc + - name: DATABASE_PASSWORD + value: password + resources: + limits: + memory: "528Mi" + cpu: "400m" + ports: + - containerPort: 5432 + volumeMounts: + - name: secret-volume + readOnly: true + mountPath: /organizations + +--- +apiVersion: v1 +kind: Service +metadata: + name: explorerdb-service +spec: + selector: + app: explorer-db + ports: + - port: 5432 + targetPort: 5432 + diff --git a/sample-network/explorer/pv.yaml b/sample-network/explorer/pv.yaml new file mode 100644 index 00000000..c61f3279 --- /dev/null +++ b/sample-network/explorer/pv.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: mypv + labels: + type: local +spec: + #we use local node storage here! + #kubectl get storageclass + storageClassName: hostpath + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt" diff --git a/sample-network/explorer/pvc.yaml b/sample-network/explorer/pvc.yaml new file mode 100644 index 00000000..03a4c3e2 --- /dev/null +++ b/sample-network/explorer/pvc.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mypvc +spec: + storageClassName: hostpath + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 50Mi