├── README.md ├── config ├── chaincode │ └── chaincode_example02 │ │ └── chaincode_example02.go ├── configtx.yaml ├── crypto-config.yaml └── explorer │ └── app │ ├── config.json │ └── run.sh ├── images ├── slide1.jpg ├── slide2.jpg ├── slide3.jpg ├── slide4.jpg ├── slide5.jpg ├── slide6.jpg └── slide7.jpg └── kubernetes ├── blockchain-ca_deploy.yaml ├── blockchain-ca_svc.yaml ├── blockchain-explorer-app_deploy.yaml ├── blockchain-explorer-db_deploy.yaml ├── blockchain-explorer-db_svc.yaml ├── blockchain-orderer_deploy.yaml ├── blockchain-orderer_svc.yaml ├── blockchain-org1peer1_deploy.yaml ├── blockchain-org1peer1_svc.yaml ├── blockchain-org1peer2_deploy.yaml ├── blockchain-org1peer2_svc.yaml ├── blockchain-org2peer1_deploy.yaml ├── blockchain-org2peer1_svc.yaml ├── blockchain-org2peer2_deploy.yaml ├── blockchain-org2peer2_svc.yaml ├── blockchain-org3peer1_deploy.yaml ├── blockchain-org3peer1_svc.yaml ├── blockchain-org3peer2_deploy.yaml ├── blockchain-org3peer2_svc.yaml ├── blockchain-org4peer1_deploy.yaml ├── blockchain-org4peer1_svc.yaml ├── blockchain-org4peer2_deploy.yaml ├── blockchain-org4peer2_svc.yaml ├── fabric-pv.yaml ├── fabric-pvc.yaml └── fabric-tools.yaml /README.md: -------------------------------------------------------------------------------- 1 | # Blockchain Solution with Hyperledger Fabric + Hyperledger Explorer on Kubernetes 2 | 3 | 4 | **Maintainers:** [feitnomore](https://github.com/feitnomore/) 5 | 6 | This is a simple guide to help you implement a complete Blockchain solution using [Hyperledger Fabric v1.3](https://hyperledger-fabric.readthedocs.io/en/release-1.3/whatsnew.html) with [Hyperledger Explorer v0.3.7](https://www.hyperledger.org/projects/explorer) on top of a [Kubernetes](https://kubernetes.io) platform. 7 | This solution uses also [CouchDB](http://couchdb.apache.org/) as peer's backend, [Apache Kafka](https://kafka.apache.org/) topics for the orderers and a NFS Server *(Network file system)* to share data between the components. 8 | 9 | *Note: Kafka/Zookeeper are running outside Kubernetes.* 10 | 11 | *WARNING:* Use it at your own risk. 12 | 13 | ## BACKGROUND 14 | 15 | A few weeks back, I've decided to take a look at Hyperledger Fabric solution to Blockchain, as it seems to be a technology that has been seeing an increase use and also is supported by giant tech companies like IBM and Oracle for example. 16 | When I started looking at it, I've found lots of scripts like `start.sh`, `stop.sh`, `byfn.sh` and `eyfn.sh`. For me those seems like "magic", and everyone that I've talked to, stated that I should use those. 17 | While using those scripts made me start fast, I had lots of trouble figuring out what was going on *behind the scenes* and also had a really hard time trying to customize the environment or run anything different from those samples. 18 | At that point I've decided to start digging and started building a complete Blockchain environment, step-by-step, in order to see the details of how it works and how it can be achieved. This github repository is the result of my studies. 19 | 20 | ## INTRODUCTION 21 | 22 | We're going to build a complete Hyperledger Fabric v1.3 environment with CA, Orderer and 4 Organizations. In order to achieve scalability and high availability on the Orderer we're going to be using Kafka. Each Organization will have 2 peers, and each peer will have it's own CouchDB instance. We're also going to deploy Hyperledger Explorer v0.3.7 with its PostgreSQL database as well. 23 | 24 | ## ARCHITECTURE 25 | 26 | ### Infrastructure view 27 | 28 | For this environment we're going to be using a 3-node Kubernetes cluster, a 3-node Apache Zookeeper cluster (for Kafka), a 4-node Apache Kafka cluster and a NFS server. All the machines are going to be in the same network. 29 | For Kubernetes cluster we'll have the following machines: 30 | ```sh 31 | kubenode01.local.parisi.biz 32 | kubenode02.local.parisi.biz 33 | kubenode03.local.parisi.biz 34 | ``` 35 | *Note: This is a home Kubernetes environment however most of what is covered here should apply to any cloud provider that provides Kubernetes compatible services.* 36 | 37 | For Apache Zookeeper we'll have the following machines: 38 | ```sh 39 | zookeeper1.local.parisi.biz 40 | zookeeper2.local.parisi.biz 41 | zookeeper3.local.parisi.biz 42 | ``` 43 | *Note: Zookeeper is needed by Apache Kafka.* 44 | *Note: Apache Kafka should be 1.0 for Hyperledger compatibility.* 45 | *Note: Check [this link](https://dzone.com/articles/how-to-setup-kafka-cluster) for a quick guide on Kafka/Zookeeper cluster.* 46 | *Note: We're using 3 Zookeeper nodes as the minimum stated in [Hyperledger Fabric Kafka Documentation](https://hyperledger-fabric.readthedocs.io/en/release-1.3/kafka.html).* 47 | 48 | For Apache Kafka we'll have the following machines: 49 | ```sh 50 | kafka1.local.parisi.biz 51 | kafka2.local.parisi.biz 52 | kafka3.local.parisi.biz 53 | kafka4.local.parisi.biz 54 | ``` 55 | *Note: We're using Kafka 1.0 version for Hyperledger compatibility.* 56 | *Note: Check [this link](https://dzone.com/articles/how-to-setup-kafka-cluster) for a quick guide on Kafka/Zookeeper cluster.* 57 | *Note: We're using 4 Kafka nodes as the minimum stated in [Hyperledger Fabric Kafka Documentation](https://hyperledger-fabric.readthedocs.io/en/release-1.3/kafka.html).* 58 | 59 | For the NFS Server we'll have: 60 | ```sh 61 | storage.local.parisi.biz 62 | ``` 63 | *Note: Check [this link](https://www.howtoforge.com/nfs-server-and-client-on-centos-7) for a quick guide on NFS Server setup* 64 | *Note: Crypto materials, configuration files and some scripts will be saved on this shared filesystem.* 65 | *Note: Each peer will have its own CouchDB as Ledger, meaning the data will be saved there, and not on this NFS Server.* 66 | 67 | The image below represents the environment infrastructure: 68 | 69 | ![slide1.jpg](https://github.com/feitnomore/hyperledger-fabric-kubernetes/raw/master/images/slide1.jpg) 70 | 71 | 72 | *Note: It's important to have all the environment with the time in sync as we're dealing with transactions and shared storage. Please make sure you have all the time in sync. I encourage you to use NTP on your servers. On my environment I have `ntpdate` running in a cron job.* 73 | *Note: Kafka, Zookeeper and NFS Server are running outside Kubernetes.* 74 | 75 | ### Fabric Logical view 76 | 77 | This environment will have a CA and a Orderer as Kubernetes deployments: 78 | ```sh 79 | blockchain-ca 80 | blockchain-orderer 81 | ``` 82 | 83 | We'll also have 4 organizations, with each organization having 2 peers, organized in the following deployments: 84 | ```sh 85 | blockchain-org1peer1 86 | blockchain-org1peer2 87 | blockchain-org2peer1 88 | blockchain-org2peer2 89 | blockchain-org3peer1 90 | blockchain-org3peer2 91 | blockchain-org4peer1 92 | blockchain-org4peer2 93 | ``` 94 | 95 | The image below represents this logical view: 96 | 97 | ![slide2.jpg](https://github.com/feitnomore/hyperledger-fabric-kubernetes/raw/master/images/slide2.jpg) 98 | 99 | ### Explorer Logical view 100 | We're going to have Hyperledger Explorer as a WebUI for our environment. Hyperledger Explorer will run in 2 deployments as below: 101 | ```sh 102 | blockchain-explorer-db 103 | blockchain-explorer-app 104 | ``` 105 | 106 | The image below represents this logical view: 107 | 108 | ![slide3.jpg](https://github.com/feitnomore/hyperledger-fabric-kubernetes/raw/master/images/slide3.jpg) 109 | 110 | ### Detailed view 111 | Hyperledger Fabric Orderer will connect itself to the Kafka servers as image below: 112 | 113 | ![slide4.jpg](https://github.com/feitnomore/hyperledger-fabric-kubernetes/raw/master/images/slide4.jpg) 114 | 115 | Each Hyperledger Fabric Peer will have it's own CouchDB instance running as a sidecar and will connect to our NFS shared storage: 116 | 117 | ![slide5.jpg](https://github.com/feitnomore/hyperledger-fabric-kubernetes/raw/master/images/slide5.jpg) 118 | 119 | *Note: Although its not depicted above, CA, Orderer and Explorer deployments will also have access to the NFS shared storage as they need the artifacts that we're going to store there.* 120 | 121 | ## IMPLEMENTATION 122 | 123 | ### Step 1: Checking environment 124 | 125 | First let's make sure we have Kubernetes environment up & running: 126 | ```sh 127 | kubectl get nodes 128 | ``` 129 | 130 | ### Step 2: Setting up shared storage 131 | 132 | Now, assuming the NFS server is up & running and with the correct permissions, we're going to create our `PersistentVolume`. First lets create the file `kubernetes/fabric-pv.yaml` like the example below: 133 | ```yaml 134 | kind: PersistentVolume 135 | apiVersion: v1 136 | metadata: 137 | name: fabric-pv 138 | labels: 139 | type: local 140 | name: fabricfiles 141 | spec: 142 | capacity: 143 | storage: 10Gi 144 | volumeMode: Filesystem 145 | accessModes: 146 | - ReadWriteMany 147 | persistentVolumeReclaimPolicy: Retain 148 | nfs: 149 | path: /nfs/fabric 150 | server: storage.local.parisi.biz 151 | readOnly: false 152 | ``` 153 | 154 | *Note: NFS Server is running on `storage.local.parisi.biz` and the shared filesystem is `/nfs/fabric`. We're using `fabricfiles` as the name for this PersistentVolume.* 155 | 156 | Now let's apply the above configuration: 157 | ```sh 158 | kubectl apply -f kubernetes/fabric-pv.yaml 159 | ``` 160 | 161 | After that we'll need to create a `PersistentVolumeClaim`. To do that, we'll create file `kubernetes/fabric-pvc.yaml` as below: 162 | ```yaml 163 | kind: PersistentVolumeClaim 164 | apiVersion: v1 165 | metadata: 166 | name: fabric-pvc 167 | spec: 168 | accessModes: 169 | - ReadWriteMany 170 | resources: 171 | requests: 172 | storage: 10Gi 173 | selector: 174 | matchLabels: 175 | name: fabricfiles 176 | ``` 177 | *Note: We're using our previously created `fabricfiles` as the selector here.* 178 | 179 | Now let's apply the above configuration: 180 | ```sh 181 | kubectl apply -f kubernetes/fabric-pvc.yaml 182 | ``` 183 | 184 | ### Step 3: Launching a Fabric Tools helper pod 185 | 186 | In order to perform some operations on the environment like file management, peer configuration and artifact generation, we'll need a helper `Pod` running `fabric-tools`. For that we'll create file `kubernetes/fabric-tools.yaml`: 187 | ```yaml 188 | apiVersion: v1 189 | kind: Pod 190 | metadata: 191 | name: fabric-tools 192 | spec: 193 | volumes: 194 | - name: fabricfiles 195 | persistentVolumeClaim: 196 | claimName: fabric-pvc 197 | - name: dockersocket 198 | hostPath: 199 | path: /var/run/docker.sock 200 | containers: 201 | - name: fabrictools 202 | image: hyperledger/fabric-tools:amd64-1.3.0 203 | imagePullPolicy: Always 204 | command: ["sh", "-c", "sleep 48h"] 205 | env: 206 | - name: TZ 207 | value: "America/Sao_Paulo" 208 | - name: FABRIC_CFG_PATH 209 | value: "/fabric" 210 | volumeMounts: 211 | - mountPath: /fabric 212 | name: fabricfiles 213 | - mountPath: /host/var/run/docker.sock 214 | name: dockersocket 215 | ``` 216 | *Note: It's important to have the same timezone accross all network. Check TZ environment variable.* 217 | 218 | After creating the file, let's apply it to our kubernetes cluster: 219 | ```sh 220 | kubectl apply -f kubernetes/fabric-tools.yaml 221 | ``` 222 | 223 | Make sure the `fabric-tools` `Pod` is running before we continue: 224 | ```sh 225 | kubectl get pods 226 | ``` 227 | 228 | Now, assuming `fabric-tools` `Pod` is running, let's create a config directory on our shared filesystem to hold our files: 229 | ```sh 230 | kubectl exec -it fabric-tools -- mkdir /fabric/config 231 | ``` 232 | 233 | ### Step 4: Loading the config files into the storage 234 | 235 | 1 - Configtx 236 | Now we're going to create the file `config/configtx.yaml` with our network configuration, like the example below: 237 | ```yaml 238 | --- 239 | Organizations: 240 | 241 | - &OrdererOrg 242 | Name: OrdererOrg 243 | ID: OrdererMSP 244 | MSPDir: crypto-config/ordererOrganizations/example.com/msp 245 | AdminPrincipal: Role.MEMBER 246 | 247 | - &Org1 248 | Name: Org1MSP 249 | ID: Org1MSP 250 | MSPDir: crypto-config/peerOrganizations/org1.example.com/msp 251 | AdminPrincipal: Role.MEMBER 252 | AnchorPeers: 253 | - Host: blockchain-org1peer1 254 | Port: 30110 255 | - Host: blockchain-org1peer2 256 | Port: 30110 257 | 258 | - &Org2 259 | Name: Org2MSP 260 | ID: Org2MSP 261 | MSPDir: crypto-config/peerOrganizations/org2.example.com/msp 262 | AdminPrincipal: Role.MEMBER 263 | AnchorPeers: 264 | - Host: blockchain-org2peer1 265 | Port: 30110 266 | - Host: blockchain-org2peer2 267 | Port: 30110 268 | 269 | - &Org3 270 | Name: Org3MSP 271 | ID: Org3MSP 272 | MSPDir: crypto-config/peerOrganizations/org3.example.com/msp 273 | AdminPrincipal: Role.MEMBER 274 | AnchorPeers: 275 | - Host: blockchain-org3peer1 276 | Port: 30110 277 | - Host: blockchain-org3peer2 278 | Port: 30110 279 | 280 | - &Org4 281 | Name: Org4MSP 282 | ID: Org4MSP 283 | MSPDir: crypto-config/peerOrganizations/org4.example.com/msp 284 | AdminPrincipal: Role.MEMBER 285 | AnchorPeers: 286 | - Host: blockchain-org4peer1 287 | Port: 30110 288 | - Host: blockchain-org4peer2 289 | Port: 30110 290 | 291 | Orderer: &OrdererDefaults 292 | 293 | OrdererType: kafka 294 | Addresses: 295 | - blockchain-orderer:31010 296 | 297 | BatchTimeout: 1s 298 | BatchSize: 299 | MaxMessageCount: 50 300 | AbsoluteMaxBytes: 99 MB 301 | PreferredMaxBytes: 512 KB 302 | 303 | Kafka: 304 | Brokers: 305 | - kafka1.local.parisi.biz:9092 306 | - kafka2.local.parisi.biz:9092 307 | - kafka3.local.parisi.biz:9092 308 | - kafka4.local.parisi.biz:9092 309 | 310 | Organizations: 311 | 312 | Application: &ApplicationDefaults 313 | 314 | Organizations: 315 | 316 | Profiles: 317 | 318 | FourOrgsOrdererGenesis: 319 | Orderer: 320 | <<: *OrdererDefaults 321 | Organizations: 322 | - *OrdererOrg 323 | Consortiums: 324 | SampleConsortium: 325 | Organizations: 326 | - *Org1 327 | - *Org2 328 | - *Org3 329 | - *Org4 330 | FourOrgsChannel: 331 | Consortium: SampleConsortium 332 | Application: 333 | <<: *ApplicationDefaults 334 | Organizations: 335 | - *Org1 336 | - *Org2 337 | - *Org3 338 | - *Org4 339 | ``` 340 | *Note: The file reflects the topology discussed on the architecture presented before.* 341 | *Note: Pay attention to the Kafka brokers URLs.* 342 | *Note: Its important to have Anchor Peers configuration here as it impacts Hyperledger Fabric Service Discovery.* 343 | *Note: BatchTimeout and BatchSize impacts directly in the performance of your environment in terms of quantity of transactions that are processed.* 344 | 345 | Now let's copy the file we just created to our shared filesystem: 346 | ```sh 347 | kubectl cp config/configtx.yaml fabric-tools:/fabric/config/ 348 | ``` 349 | 350 | 2 - Crypto-config 351 | Now lets create the file `config/crypto-config.yaml` like below: 352 | ```yaml 353 | OrdererOrgs: 354 | - Name: Orderer 355 | Domain: example.com 356 | Specs: 357 | - Hostname: orderer 358 | PeerOrgs: 359 | - Name: Org1 360 | Domain: org1.example.com 361 | Template: 362 | Count: 2 363 | Users: 364 | Count: 1 365 | - Name: Org2 366 | Domain: org2.example.com 367 | Template: 368 | Count: 2 369 | Users: 370 | Count: 1 371 | - Name: Org3 372 | Domain: org3.example.com 373 | Template: 374 | Count: 2 375 | Users: 376 | Count: 1 377 | - Name: Org4 378 | Domain: org4.example.com 379 | Template: 380 | Count: 2 381 | Users: 382 | Count: 1 383 | ``` 384 | 385 | Let's copy the file to our shared filesystem: 386 | ```sh 387 | kubectl cp config/crypto-config.yaml fabric-tools:/fabric/config/ 388 | ``` 389 | 390 | 3 - Chaincode 391 | It's time to copy our example chaincode to the shared filesystem. In this case we'll be using balance-transfer example: 392 | ```sh 393 | kubectl cp config/chaincode/ fabric-tools:/fabric/config/ 394 | ``` 395 | 396 | ### Step 5: Creating the necessary artifacts 397 | 398 | 1 - cryptogen 399 | Time to generate our crypto material: 400 | ```sh 401 | kubectl exec -it fabric-tools -- /bin/bash 402 | cryptogen generate --config /fabric/config/crypto-config.yaml 403 | exit 404 | ``` 405 | 406 | Now we're going to copy our files to the correct path and rename the key files: 407 | ```sh 408 | kubectl exec -it fabric-tools -- /bin/bash 409 | cp -r crypto-config /fabric/ 410 | for file in $(find /fabric/ -iname *_sk); do echo $file; dir=$(dirname $file); mv ${dir}/*_sk ${dir}/key.pem; done 411 | exit 412 | ``` 413 | 414 | 415 | 2 - configtxgen 416 | Now we're going to copy the artifacts to the correct path and generate the genesis block: 417 | ```sh 418 | kubectl exec -it fabric-tools -- /bin/bash 419 | cp /fabric/config/configtx.yaml /fabric/ 420 | cd /fabric 421 | configtxgen -profile FourOrgsOrdererGenesis -outputBlock genesis.block 422 | exit 423 | ``` 424 | 425 | 3 - Anchor Peers 426 | Lets create the Anchor Peers configuration files using configtxgen: 427 | ```sh 428 | kubectl exec -it fabric-tools -- /bin/bash 429 | cd /fabric 430 | configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./Org1MSPanchors.tx -channelID channel1 -asOrg Org1MSP 431 | configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./Org2MSPanchors.tx -channelID channel1 -asOrg Org2MSP 432 | configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./Org3MSPanchors.tx -channelID channel1 -asOrg Org3MSP 433 | configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./Org4MSPanchors.tx -channelID channel1 -asOrg Org4MSP 434 | exit 435 | ``` 436 | *Note: The generated files will be used later to update channel configuration with the respective Anchor Peers. This step is important for Hyperledger Fabric Service Discovery to work properly.* 437 | 438 | 4 - Fix Permissions 439 | We need to fix the files permissions on our shared filesystem now: 440 | ```sh 441 | kubectl exec -it fabric-tools -- /bin/bash 442 | chmod a+rx /fabric/* -R 443 | exit 444 | ``` 445 | 446 | 447 | ### Step 6: Setting up Fabric CA 448 | 449 | Create the `kubernetes/blockchain-ca_deploy.yaml` file with the following `Deployment` description: 450 | ```yaml 451 | apiVersion: extensions/v1beta1 452 | kind: Deployment 453 | metadata: 454 | name: blockchain-ca 455 | spec: 456 | replicas: 1 457 | template: 458 | metadata: 459 | labels: 460 | name: ca 461 | spec: 462 | volumes: 463 | - name: fabricfiles 464 | persistentVolumeClaim: 465 | claimName: fabric-pvc 466 | 467 | containers: 468 | - name: ca 469 | image: hyperledger/fabric-ca:amd64-1.3.0 470 | command: ["sh", "-c", "fabric-ca-server start -b admin:adminpw -d"] 471 | env: 472 | - name: TZ 473 | value: "America/Sao_Paulo" 474 | - name: FABRIC_CA_SERVER_CA_NAME 475 | value: "CA1" 476 | - name: FABRIC_CA_SERVER_CA_CERTFILE 477 | value: /fabric/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem 478 | - name: FABRIC_CA_SERVER_CA_KEYFILE 479 | value: /fabric/crypto-config/peerOrganizations/org1.example.com/ca/key.pem 480 | - name: FABRIC_CA_SERVER_DEBUG 481 | value: "true" 482 | - name: FABRIC_CA_SERVER_TLS_ENABLED 483 | value: "false" 484 | - name: FABRIC_CA_SERVER_TLS_CERTFILE 485 | value: /certs/ca0a-cert.pem 486 | - name: FABRIC_CA_SERVER_TLS_KEYFILE 487 | value: /certs/ca0a-key.pem 488 | - name: GODEBUG 489 | value: "netdns=go" 490 | volumeMounts: 491 | - mountPath: /fabric 492 | name: fabricfiles 493 | ``` 494 | *Note: The CA uses our shared filesystem.* 495 | *Note: The timezone configuration is important for certificate validation and expiration.* 496 | 497 | Now let's apply the configuration: 498 | ```sh 499 | kubectl apply -f kubernetes/blockchain-ca_deploy.yaml 500 | ``` 501 | 502 | Create the file `kubernetes/blockchain-ca_svc.yaml` with the following `Service` description: 503 | ```yaml 504 | apiVersion: v1 505 | kind: Service 506 | metadata: 507 | name: blockchain-ca 508 | labels: 509 | run: blockchain-ca 510 | spec: 511 | type: ClusterIP 512 | selector: 513 | name: ca 514 | ports: 515 | - protocol: TCP 516 | port: 30054 517 | targetPort: 7054 518 | name: grpc 519 | - protocol: TCP 520 | port: 7054 521 | name: grpc1 522 | ``` 523 | 524 | Now, apply the configuration: 525 | ```sh 526 | kubectl apply -f kubernetes/blockchain-ca_svc.yaml 527 | ``` 528 | 529 | 530 | ### Step 7: Setting up Fabric Orderer 531 | 532 | Create the file `kubernetes/blockchain-orderer_deploy.yaml` with the following `Deployment` description: 533 | ```yaml 534 | apiVersion: extensions/v1beta1 535 | kind: Deployment 536 | metadata: 537 | name: blockchain-orderer 538 | spec: 539 | replicas: 3 540 | template: 541 | metadata: 542 | labels: 543 | name: orderer 544 | spec: 545 | volumes: 546 | - name: fabricfiles 547 | persistentVolumeClaim: 548 | claimName: fabric-pvc 549 | 550 | containers: 551 | - name: orderer 552 | image: hyperledger/fabric-orderer:amd64-1.3.0 553 | command: ["sh", "-c", "orderer"] 554 | env: 555 | - name: TZ 556 | value: "America/Sao_Paulo" 557 | - name: ORDERER_CFG_PATH 558 | value: /fabric/ 559 | - name: ORDERER_GENERAL_LEDGERTYPE 560 | value: file 561 | - name: ORDERER_FILELEDGER_LOCATION 562 | value: /fabric/ledger/orderer 563 | - name: ORDERER_GENERAL_BATCHTIMEOUT 564 | value: 1s 565 | - name: ORDERER_GENERAL_BATCHSIZE_MAXMESSAGECOUNT 566 | value: "10" 567 | - name: ORDERER_GENERAL_MAXWINDOWSIZE 568 | value: "1000" 569 | - name: CONFIGTX_GENERAL_ORDERERTYPE 570 | value: kafka 571 | - name: CONFIGTX_ORDERER_KAFKA_BROKERS 572 | value: "kafka1.local.parisi.biz:9092,kafka2.local.parisi.biz:9092,kafka3.local.parisi.biz:9092,kafka4.local.parisi.biz:9092" 573 | - name: ORDERER_KAFKA_RETRY_SHORTINTERVAL 574 | value: 1s 575 | - name: ORDERER_KAFKA_RETRY_SHORTTOTAL 576 | value: 30s 577 | - name: ORDERER_KAFKA_VERBOSE 578 | value: "true" 579 | - name: CONFIGTX_ORDERER_ADDRESSES 580 | value: "blockchain-orderer:31010" 581 | - name: ORDERER_GENERAL_LISTENADDRESS 582 | value: 0.0.0.0 583 | - name: ORDERER_GENERAL_LISTENPORT 584 | value: "31010" 585 | - name: ORDERER_GENERAL_LOGLEVEL 586 | value: debug 587 | - name: ORDERER_GENERAL_LOCALMSPDIR 588 | value: /fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp 589 | - name: ORDERER_GENERAL_LOCALMSPID 590 | value: OrdererMSP 591 | - name: ORDERER_GENERAL_GENESISMETHOD 592 | value: file 593 | - name: ORDERER_GENERAL_GENESISFILE 594 | value: /fabric/genesis.block 595 | - name: ORDERER_GENERAL_GENESISPROFILE 596 | value: initial 597 | - name: ORDERER_GENERAL_TLS_ENABLED 598 | value: "false" 599 | - name: GODEBUG 600 | value: "netdns=go" 601 | - name: ORDERER_GENERAL_LEDGERTYPE 602 | value: "ram" 603 | volumeMounts: 604 | - mountPath: /fabric 605 | name: fabricfiles 606 | ``` 607 | *Note: Because we're dealing with transactions, timezones needs to be in sync everywhere.* 608 | *Note: The Orderer also uses our shared filesystem.* 609 | *Note: Orderer is using Kafka.* 610 | *Note: Kafka Brokers previoulsy set on configtx are now listed under CONFIGTX_ORDERER_KAFKA_BROKERS environment variable.* 611 | *Note: We're using a deployment with 3 Orderers.* 612 | 613 | Let's apply the configuration: 614 | ```sh 615 | kubectl apply -f kubernetes/blockchain-orderer_deploy.yaml 616 | ``` 617 | 618 | Create the file `kubernetes/blockchain-orderer_svc.yaml` with the following `Service` description: 619 | ```yaml 620 | apiVersion: v1 621 | kind: Service 622 | metadata: 623 | name: blockchain-orderer 624 | labels: 625 | run: blockchain-orderer 626 | spec: 627 | type: ClusterIP 628 | selector: 629 | name: orderer 630 | ports: 631 | - protocol: TCP 632 | port: 31010 633 | name: grpc 634 | ``` 635 | *Note: This service will Load Balance between the 3 Orderer Pods created in the previous Deployment.* 636 | 637 | 638 | Now, apply the configuration: 639 | ```sh 640 | kubectl apply -f kubernetes/blockchain-orderer_svc.yaml 641 | ``` 642 | 643 | ### Step 8: Org1MSP 644 | 645 | - Create Org1MSP Peer1 Deployment 646 | Create the file `kubernetes/blockchain-org1peer1_deploy.yaml` with the following `Deployment`: 647 | ```yaml 648 | apiVersion: extensions/v1beta1 649 | kind: Deployment 650 | metadata: 651 | name: blockchain-org1peer1 652 | spec: 653 | replicas: 1 654 | template: 655 | metadata: 656 | labels: 657 | name: org1peer1 658 | spec: 659 | volumes: 660 | - name: fabricfiles 661 | persistentVolumeClaim: 662 | claimName: fabric-pvc 663 | - name: dockersocket 664 | hostPath: 665 | path: /var/run/docker.sock 666 | 667 | containers: 668 | - name: peer 669 | image: hyperledger/fabric-peer:amd64-1.3.0 670 | command: ["sh", "-c", "peer node start"] 671 | env: 672 | - name: TZ 673 | value: "America/Sao_Paulo" 674 | - name: CORE_PEER_ADDRESSAUTODETECT 675 | value: "true" 676 | - name: CORE_PEER_NETWORKID 677 | value: nid1 678 | - name: CORE_PEER_ID 679 | value: blockchain-org1peer1 680 | - name: CORE_PEER_ADDRESS 681 | value: blockchain-org1peer1:30110 682 | - name: CORE_PEER_LISTENADDRESS 683 | value: 0.0.0.0:30110 684 | - name: CORE_PEER_EVENTS_ADDRESS 685 | value: 0.0.0.0:30111 686 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 687 | value: blockchain-org1peer1:30110 688 | - name: CORE_PEER_GOSSIP_ENDPOINT 689 | value: blockchain-org1peer1:30110 690 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 691 | value: blockchain-org1peer1:30110 692 | - name: CORE_PEER_GOSSIP_ORGLEADER 693 | value: "false" 694 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 695 | value: "true" 696 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 697 | value: "true" 698 | - name: CORE_PEER_COMMITTER_ENABLED 699 | value: "true" 700 | - name: CORE_PEER_PROFILE_ENABLED 701 | value: "true" 702 | - name: CORE_VM_ENDPOINT 703 | value: unix:///host/var/run/docker.sock 704 | - name: CORE_PEER_LOCALMSPID 705 | value: Org1MSP 706 | - name: CORE_PEER_MSPCONFIGPATH 707 | value: /fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/ 708 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 709 | value: "pbft" 710 | - name: CORE_PBFT_GENERAL_MODE 711 | value: "classic" 712 | - name: CORE_PBFT_GENERAL_N 713 | value: "4" 714 | - name: CORE_LOGGING_LEVEL 715 | value: debug 716 | - name: CORE_LOGGING_PEER 717 | value: debug 718 | - name: CORE_LOGGING_CAUTHDSL 719 | value: debug 720 | - name: CORE_LOGGING_GOSSIP 721 | value: debug 722 | - name: CORE_LOGGING_LEDGER 723 | value: debug 724 | - name: CORE_LOGGING_MSP 725 | value: info 726 | - name: CORE_LOGGING_POLICIES 727 | value: debug 728 | - name: CORE_LOGGING_GRPC 729 | value: debug 730 | - name: CORE_PEER_TLS_ENABLED 731 | value: "false" 732 | - name: CORE_LEDGER_STATE_STATEDATABASE 733 | value: "CouchDB" 734 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 735 | value: "localhost:5984" 736 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 737 | value: "hyperledgeruser" 738 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 739 | value: "hyperledgerpass" 740 | - name: FABRIC_CFG_PATH 741 | value: /etc/hyperledger/fabric/ 742 | - name: ORDERER_URL 743 | value: blockchain-orderer:31010 744 | - name: GODEBUG 745 | value: "netdns=go" 746 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 747 | value: "true" 748 | volumeMounts: 749 | - mountPath: /fabric 750 | name: fabricfiles 751 | - mountPath: /host/var/run/docker.sock 752 | name: dockersocket 753 | - name: couchdb 754 | image: hyperledger/fabric-couchdb:amd64-0.4.14 755 | env: 756 | - name: TZ 757 | value: "America/Sao_Paulo" 758 | - name: COUCHDB_USER 759 | value: "hyperledgeruser" 760 | - name: COUCHDB_PASSWORD 761 | value: "hyperledgerpass" 762 | ``` 763 | *Note: Because we're dealing with transactions, its important that every pod is running in the same timezone. Pay attention to the TZ environment variable.* 764 | *Note: CORE_PEER_GOSSIP_BOOTSTRAP, CORE_PEER_GOSSIP_ENDPOINT and CORE_PEER_GOSSIP_EXTERNALENDPOINT are critical for the Hyperledger Fabric Service Discovery to work.* 765 | *Note: Volume dockersocket is used in order for the peer to have access to the docker daemon running on the host the peer is running, to be able to launch the chaincode container* 766 | *Note: The chaincode container will be launched directly into Docker Daemon, and will not show up in Kubernetes.* 767 | *Note: There is a sidecar container running CouchDB. There are environment variables setting the peer to use this CouchDB instance.* 768 | 769 | - Create Org1MSP Peer2 Deployment 770 | Create the file `kubernetes/blockchain-org1peer2_deploy.yaml` with the following `Deployment`: 771 | ```yaml 772 | apiVersion: extensions/v1beta1 773 | kind: Deployment 774 | metadata: 775 | name: blockchain-org1peer2 776 | spec: 777 | replicas: 1 778 | template: 779 | metadata: 780 | labels: 781 | name: org1peer2 782 | spec: 783 | volumes: 784 | - name: fabricfiles 785 | persistentVolumeClaim: 786 | claimName: fabric-pvc 787 | - name: dockersocket 788 | hostPath: 789 | path: /var/run/docker.sock 790 | 791 | containers: 792 | - name: peer 793 | image: hyperledger/fabric-peer:amd64-1.3.0 794 | command: ["sh", "-c", "peer node start"] 795 | env: 796 | - name: TZ 797 | value: "America/Sao_Paulo" 798 | - name: CORE_PEER_ADDRESSAUTODETECT 799 | value: "true" 800 | - name: CORE_PEER_NETWORKID 801 | value: nid1 802 | - name: CORE_PEER_ID 803 | value: blockchain-org1peer2 804 | - name: CORE_PEER_ADDRESS 805 | value: blockchain-org1peer2:30110 806 | - name: CORE_PEER_LISTENADDRESS 807 | value: 0.0.0.0:30110 808 | - name: CORE_PEER_EVENTS_ADDRESS 809 | value: 0.0.0.0:30111 810 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 811 | value: blockchain-org1peer2:30110 812 | - name: CORE_PEER_GOSSIP_ENDPOINT 813 | value: blockchain-org1peer2:30110 814 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 815 | value: blockchain-org1peer2:30110 816 | - name: CORE_PEER_GOSSIP_ORGLEADER 817 | value: "false" 818 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 819 | value: "true" 820 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 821 | value: "true" 822 | - name: CORE_PEER_COMMITTER_ENABLED 823 | value: "true" 824 | - name: CORE_PEER_PROFILE_ENABLED 825 | value: "true" 826 | - name: CORE_VM_ENDPOINT 827 | value: unix:///host/var/run/docker.sock 828 | - name: CORE_PEER_LOCALMSPID 829 | value: Org1MSP 830 | - name: CORE_PEER_MSPCONFIGPATH 831 | value: /fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp/ 832 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 833 | value: "pbft" 834 | - name: CORE_PBFT_GENERAL_MODE 835 | value: "classic" 836 | - name: CORE_PBFT_GENERAL_N 837 | value: "4" 838 | - name: CORE_LOGGING_LEVEL 839 | value: debug 840 | - name: CORE_LOGGING_PEER 841 | value: debug 842 | - name: CORE_LOGGING_CAUTHDSL 843 | value: debug 844 | - name: CORE_LOGGING_GOSSIP 845 | value: debug 846 | - name: CORE_LOGGING_LEDGER 847 | value: debug 848 | - name: CORE_LOGGING_MSP 849 | value: info 850 | - name: CORE_LOGGING_POLICIES 851 | value: debug 852 | - name: CORE_LOGGING_GRPC 853 | value: debug 854 | - name: CORE_PEER_TLS_ENABLED 855 | value: "false" 856 | - name: CORE_LEDGER_STATE_STATEDATABASE 857 | value: "CouchDB" 858 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 859 | value: "localhost:5984" 860 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 861 | value: "hyperledgeruser" 862 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 863 | value: "hyperledgerpass" 864 | - name: FABRIC_CFG_PATH 865 | value: /etc/hyperledger/fabric/ 866 | - name: ORDERER_URL 867 | value: blockchain-orderer:31010 868 | - name: GODEBUG 869 | value: "netdns=go" 870 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 871 | value: "true" 872 | volumeMounts: 873 | - mountPath: /fabric 874 | name: fabricfiles 875 | - mountPath: /host/var/run/docker.sock 876 | name: dockersocket 877 | - name: couchdb 878 | image: hyperledger/fabric-couchdb:amd64-0.4.14 879 | env: 880 | - name: TZ 881 | value: "America/Sao_Paulo" 882 | - name: COUCHDB_USER 883 | value: "hyperledgeruser" 884 | - name: COUCHDB_PASSWORD 885 | value: "hyperledgerpass" 886 | ``` 887 | *Note: The peer uses our shared filesystem.* 888 | *Note: Because we're dealing with transactions, its important that every pod is running in the same timezone. Pay attention to the TZ environment variable.* 889 | *Note: CORE_PEER_GOSSIP_BOOTSTRAP, CORE_PEER_GOSSIP_ENDPOINT and CORE_PEER_GOSSIP_EXTERNALENDPOINT are critical for the Hyperledger Fabric Service Discovery to work.* 890 | *Note: Volume dockersocket is used in order for the peer to have access to the docker daemon running on the host the peer is running, to be able to launch the chaincode container* 891 | *Note: The chaincode container will be launched directly into Docker Daemon, and will not show up in Kubernetes.* 892 | *Note: There is a sidecar container running CouchDB. There are environment variables setting the peer to use this CouchDB instance.* 893 | 894 | - Create Org1MSP Peer1 Service 895 | Create the file `kubernetes/blockchain-org1peer1_svc.yaml` with the `Service` below: 896 | ```yaml 897 | apiVersion: v1 898 | kind: Service 899 | metadata: 900 | name: blockchain-org1peer1 901 | labels: 902 | run: blockchain-org1peer1 903 | spec: 904 | type: ClusterIP 905 | selector: 906 | name: org1peer1 907 | ports: 908 | - protocol: TCP 909 | port: 30110 910 | name: grpc 911 | - protocol: TCP 912 | port: 30111 913 | name: events 914 | - protocol: TCP 915 | port: 5984 916 | name: couchdb 917 | ``` 918 | - Create Org1MSP Peer2 Service 919 | Create the file `kubernetes/blockchain-org1peer2_svc.yaml` with the `Service` below: 920 | ```yaml 921 | apiVersion: v1 922 | kind: Service 923 | metadata: 924 | name: blockchain-org1peer2 925 | labels: 926 | run: blockchain-org1peer2 927 | spec: 928 | type: ClusterIP 929 | selector: 930 | name: org1peer2 931 | ports: 932 | - protocol: TCP 933 | port: 30110 934 | name: grpc 935 | - protocol: TCP 936 | port: 30111 937 | name: events 938 | - protocol: TCP 939 | port: 5984 940 | name: couchdb 941 | ``` 942 | - Apply Configuration 943 | Now we're going to apply the previously created files: 944 | ```sh 945 | kubectl apply -f kubernetes/blockchain-org1peer1_deploy.yaml 946 | kubectl apply -f kubernetes/blockchain-org1peer2_deploy.yaml 947 | kubectl apply -f kubernetes/blockchain-org1peer1_svc.yaml 948 | kubectl apply -f kubernetes/blockchain-org1peer2_svc.yaml 949 | ``` 950 | 951 | ### Step 9: Org2MSP 952 | 953 | - Create Org2MSP Peer1 Deployment 954 | Create the file `kubernetes/blockchain-org2peer1_deploy.yaml` with the following `Deployment`: 955 | ```yaml 956 | apiVersion: extensions/v1beta1 957 | kind: Deployment 958 | metadata: 959 | name: blockchain-org2peer1 960 | spec: 961 | replicas: 1 962 | template: 963 | metadata: 964 | labels: 965 | name: org2peer1 966 | spec: 967 | volumes: 968 | - name: fabricfiles 969 | persistentVolumeClaim: 970 | claimName: fabric-pvc 971 | - name: dockersocket 972 | hostPath: 973 | path: /var/run/docker.sock 974 | 975 | containers: 976 | - name: peer 977 | image: hyperledger/fabric-peer:amd64-1.3.0 978 | command: ["sh", "-c", "peer node start"] 979 | env: 980 | - name: TZ 981 | value: "America/Sao_Paulo" 982 | - name: CORE_PEER_ADDRESSAUTODETECT 983 | value: "true" 984 | - name: CORE_PEER_ID 985 | value: blockchain-org2peer1 986 | - name: CORE_PEER_NETWORKID 987 | value: nid1 988 | - name: CORE_PEER_ADDRESS 989 | value: blockchain-org2peer1:30110 990 | - name: CORE_PEER_LISTENADDRESS 991 | value: 0.0.0.0:30110 992 | - name: CORE_PEER_EVENTS_ADDRESS 993 | value: 0.0.0.0:30111 994 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 995 | value: blockchain-org2peer1:30110 996 | - name: CORE_PEER_GOSSIP_ENDPOINT 997 | value: blockchain-org2peer1:30110 998 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 999 | value: blockchain-org2peer1:30110 1000 | - name: CORE_PEER_GOSSIP_ORGLEADER 1001 | value: "false" 1002 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 1003 | value: "true" 1004 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 1005 | value: "true" 1006 | - name: CORE_PEER_COMMITTER_ENABLED 1007 | value: "false" 1008 | - name: CORE_PEER_PROFILE_ENABLED 1009 | value: "true" 1010 | - name: CORE_VM_ENDPOINT 1011 | value: unix:///host/var/run/docker.sock 1012 | - name: CORE_PEER_LOCALMSPID 1013 | value: Org2MSP 1014 | - name: CORE_PEER_MSPCONFIGPATH 1015 | value: /fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/ 1016 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 1017 | value: "pbft" 1018 | - name: CORE_PBFT_GENERAL_MODE 1019 | value: "classic" 1020 | - name: CORE_PBFT_GENERAL_N 1021 | value: "4" 1022 | - name: CORE_LOGGING_LEVEL 1023 | value: debug 1024 | - name: CORE_LOGGING_PEER 1025 | value: debug 1026 | - name: CORE_LOGGING_CAUTHDSL 1027 | value: debug 1028 | - name: CORE_LOGGING_GOSSIP 1029 | value: debug 1030 | - name: CORE_LOGGING_LEDGER 1031 | value: debug 1032 | - name: CORE_LOGGING_MSP 1033 | value: debug 1034 | - name: CORE_LOGGING_POLICIES 1035 | value: debug 1036 | - name: CORE_LOGGING_GRPC 1037 | value: debug 1038 | - name: CORE_PEER_TLS_ENABLED 1039 | value: "false" 1040 | - name: CORE_LEDGER_STATE_STATEDATABASE 1041 | value: "CouchDB" 1042 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 1043 | value: "localhost:5984" 1044 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 1045 | value: "hyperledgeruser" 1046 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 1047 | value: "hyperledgerpass" 1048 | - name: FABRIC_CFG_PATH 1049 | value: /etc/hyperledger/fabric/ 1050 | - name: ORDERER_URL 1051 | value: blockchain-orderer:31010 1052 | - name: GODEBUG 1053 | value: "netdns=go" 1054 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 1055 | value: "true" 1056 | volumeMounts: 1057 | - mountPath: /fabric 1058 | name: fabricfiles 1059 | - mountPath: /host/var/run/docker.sock 1060 | name: dockersocket 1061 | - name: couchdb 1062 | image: hyperledger/fabric-couchdb:amd64-0.4.14 1063 | env: 1064 | - name: TZ 1065 | value: "America/Sao_Paulo" 1066 | - name: COUCHDB_USER 1067 | value: "hyperledgeruser" 1068 | - name: COUCHDB_PASSWORD 1069 | value: "hyperledgerpass" 1070 | ``` 1071 | *Note: The peer uses our shared filesystem.* 1072 | *Note: Because we're dealing with transactions, its important that every pod is running in the same timezone. Pay attention to the TZ environment variable.* 1073 | *Note: CORE_PEER_GOSSIP_BOOTSTRAP, CORE_PEER_GOSSIP_ENDPOINT and CORE_PEER_GOSSIP_EXTERNALENDPOINT are critical for the Hyperledger Fabric Service Discovery to work.* 1074 | *Note: Volume dockersocket is used in order for the peer to have access to the docker daemon running on the host the peer is running, to be able to launch the chaincode container* 1075 | *Note: The chaincode container will be launched directly into Docker Daemon, and will not show up in Kubernetes.* 1076 | *Note: There is a sidecar container running CouchDB. There are environment variables setting the peer to use this CouchDB instance.* 1077 | 1078 | - Create Org2MSP Peer2 Deployment 1079 | Create the file `kubernetes/blockchain-org2peer2_deploy.yaml` the following `Deployment`: 1080 | ```yaml 1081 | apiVersion: extensions/v1beta1 1082 | kind: Deployment 1083 | metadata: 1084 | name: blockchain-org2peer2 1085 | spec: 1086 | replicas: 1 1087 | template: 1088 | metadata: 1089 | labels: 1090 | name: org2peer2 1091 | spec: 1092 | volumes: 1093 | - name: fabricfiles 1094 | persistentVolumeClaim: 1095 | claimName: fabric-pvc 1096 | - name: dockersocket 1097 | hostPath: 1098 | path: /var/run/docker.sock 1099 | 1100 | containers: 1101 | - name: peer 1102 | image: hyperledger/fabric-peer:amd64-1.3.0 1103 | command: ["sh", "-c", "peer node start"] 1104 | env: 1105 | - name: TZ 1106 | value: "America/Sao_Paulo" 1107 | - name: CORE_PEER_ADDRESSAUTODETECT 1108 | value: "true" 1109 | - name: CORE_PEER_ID 1110 | value: blockchain-org2peer2 1111 | - name: CORE_PEER_NETWORKID 1112 | value: nid1 1113 | - name: CORE_PEER_ADDRESS 1114 | value: blockchain-org2peer2:30110 1115 | - name: CORE_PEER_LISTENADDRESS 1116 | value: 0.0.0.0:30110 1117 | - name: CORE_PEER_EVENTS_ADDRESS 1118 | value: 0.0.0.0:30111 1119 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 1120 | value: blockchain-org2peer2:30110 1121 | - name: CORE_PEER_GOSSIP_ENDPOINT 1122 | value: blockchain-org2peer2:30110 1123 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 1124 | value: blockchain-org2peer2:30110 1125 | - name: CORE_PEER_GOSSIP_ORGLEADER 1126 | value: "false" 1127 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 1128 | value: "true" 1129 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 1130 | value: "true" 1131 | - name: CORE_PEER_COMMITTER_ENABLED 1132 | value: "false" 1133 | - name: CORE_PEER_PROFILE_ENABLED 1134 | value: "true" 1135 | - name: CORE_VM_ENDPOINT 1136 | value: unix:///host/var/run/docker.sock 1137 | - name: CORE_PEER_LOCALMSPID 1138 | value: Org2MSP 1139 | - name: CORE_PEER_MSPCONFIGPATH 1140 | value: /fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/ 1141 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 1142 | value: "pbft" 1143 | - name: CORE_PBFT_GENERAL_MODE 1144 | value: "classic" 1145 | - name: CORE_PBFT_GENERAL_N 1146 | value: "4" 1147 | - name: CORE_LOGGING_LEVEL 1148 | value: debug 1149 | - name: CORE_LOGGING_PEER 1150 | value: debug 1151 | - name: CORE_LOGGING_CAUTHDSL 1152 | value: debug 1153 | - name: CORE_LOGGING_GOSSIP 1154 | value: debug 1155 | - name: CORE_LOGGING_LEDGER 1156 | value: debug 1157 | - name: CORE_LOGGING_MSP 1158 | value: debug 1159 | - name: CORE_LOGGING_POLICIES 1160 | value: debug 1161 | - name: CORE_LOGGING_GRPC 1162 | value: debug 1163 | - name: CORE_PEER_TLS_ENABLED 1164 | value: "false" 1165 | - name: CORE_LEDGER_STATE_STATEDATABASE 1166 | value: "CouchDB" 1167 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 1168 | value: "localhost:5984" 1169 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 1170 | value: "hyperledgeruser" 1171 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 1172 | value: "hyperledgerpass" 1173 | - name: FABRIC_CFG_PATH 1174 | value: /etc/hyperledger/fabric/ 1175 | - name: ORDERER_URL 1176 | value: blockchain-orderer:31010 1177 | - name: GODEBUG 1178 | value: "netdns=go" 1179 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 1180 | value: "true" 1181 | volumeMounts: 1182 | - mountPath: /fabric 1183 | name: fabricfiles 1184 | - mountPath: /host/var/run/docker.sock 1185 | name: dockersocket 1186 | - name: couchdb 1187 | image: hyperledger/fabric-couchdb:amd64-0.4.14 1188 | env: 1189 | - name: TZ 1190 | value: "America/Sao_Paulo" 1191 | - name: COUCHDB_USER 1192 | value: "hyperledgeruser" 1193 | - name: COUCHDB_PASSWORD 1194 | value: "hyperledgerpass" 1195 | ``` 1196 | *Note: The peer uses our shared filesystem.* 1197 | *Note: Because we're dealing with transactions, its important that every pod is running in the same timezone. Pay attention to the TZ environment variable.* 1198 | *Note: CORE_PEER_GOSSIP_BOOTSTRAP, CORE_PEER_GOSSIP_ENDPOINT and CORE_PEER_GOSSIP_EXTERNALENDPOINT are critical for the Hyperledger Fabric Service Discovery to work.* 1199 | *Note: Volume dockersocket is used in order for the peer to have access to the docker daemon running on the host the peer is running, to be able to launch the chaincode container* 1200 | *Note: The chaincode container will be launched directly into Docker Daemon, and will not show up in Kubernetes.* 1201 | *Note: There is a sidecar container running CouchDB. There are environment variables setting the peer to use this CouchDB instance.* 1202 | 1203 | - Create Org2MSP Peer1 Service 1204 | Create the file `kubernetes/blockchain-org2peer1_svc.yaml` with the `Service` below: 1205 | ```yaml 1206 | apiVersion: v1 1207 | kind: Service 1208 | metadata: 1209 | name: blockchain-org2peer1 1210 | labels: 1211 | run: blockchain-org2peer1 1212 | spec: 1213 | type: ClusterIP 1214 | selector: 1215 | name: org2peer1 1216 | ports: 1217 | - protocol: TCP 1218 | port: 30110 1219 | name: grpc 1220 | - protocol: TCP 1221 | port: 30111 1222 | name: events 1223 | - protocol: TCP 1224 | port: 5984 1225 | name: couchdb 1226 | ``` 1227 | - Create Org2MSP Peer2 Service 1228 | Create the file `kubernetes/blockchain-org2peer2_svc.yaml` with the `Service` below: 1229 | ```yaml 1230 | apiVersion: v1 1231 | kind: Service 1232 | metadata: 1233 | name: blockchain-org2peer2 1234 | labels: 1235 | run: blockchain-org2peer2 1236 | spec: 1237 | type: ClusterIP 1238 | selector: 1239 | name: org2peer2 1240 | ports: 1241 | - protocol: TCP 1242 | port: 30110 1243 | name: grpc 1244 | - protocol: TCP 1245 | port: 30111 1246 | name: events 1247 | - protocol: TCP 1248 | port: 5984 1249 | name: couchdb 1250 | ``` 1251 | 1252 | - Apply Configuration 1253 | Now we're going to apply the previously created files: 1254 | ```sh 1255 | kubectl apply -f kubernetes/blockchain-org2peer1_deploy.yaml 1256 | kubectl apply -f kubernetes/blockchain-org2peer2_deploy.yaml 1257 | kubectl apply -f kubernetes/blockchain-org2peer1_svc.yaml 1258 | kubectl apply -f kubernetes/blockchain-org2peer2_svc.yaml 1259 | ``` 1260 | 1261 | ### Step 10: Org3MSP 1262 | 1263 | - Create Org3MSP Peer1 Deployment 1264 | Create the file `kubernetes/blockchain-org3peer1_deploy.yaml` with the following `Deployment`: 1265 | ```yaml 1266 | apiVersion: extensions/v1beta1 1267 | kind: Deployment 1268 | metadata: 1269 | name: blockchain-org3peer1 1270 | spec: 1271 | replicas: 1 1272 | template: 1273 | metadata: 1274 | labels: 1275 | name: org3peer1 1276 | spec: 1277 | volumes: 1278 | - name: fabricfiles 1279 | persistentVolumeClaim: 1280 | claimName: fabric-pvc 1281 | - name: dockersocket 1282 | hostPath: 1283 | path: /var/run/docker.sock 1284 | 1285 | containers: 1286 | - name: peer 1287 | image: hyperledger/fabric-peer:amd64-1.3.0 1288 | command: ["sh", "-c", "peer node start"] 1289 | env: 1290 | - name: TZ 1291 | value: "America/Sao_Paulo" 1292 | - name: CORE_PEER_ADDRESSAUTODETECT 1293 | value: "true" 1294 | - name: CORE_PEER_ID 1295 | value: blockchain-org3peer1 1296 | - name: CORE_PEER_NETWORKID 1297 | value: nid1 1298 | - name: CORE_PEER_ADDRESS 1299 | value: blockchain-org3peer1:30110 1300 | - name: CORE_PEER_LISTENADDRESS 1301 | value: 0.0.0.0:30110 1302 | - name: CORE_PEER_EVENTS_ADDRESS 1303 | value: 0.0.0.0:30111 1304 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 1305 | value: blockchain-org3peer1:30110 1306 | - name: CORE_PEER_GOSSIP_ENDPOINT 1307 | value: blockchain-org3peer1:30110 1308 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 1309 | value: blockchain-org3peer1:30110 1310 | - name: CORE_PEER_GOSSIP_ORGLEADER 1311 | value: "false" 1312 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 1313 | value: "true" 1314 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 1315 | value: "true" 1316 | - name: CORE_PEER_COMMITTER_ENABLED 1317 | value: "false" 1318 | - name: CORE_PEER_PROFILE_ENABLED 1319 | value: "true" 1320 | - name: CORE_VM_ENDPOINT 1321 | value: unix:///host/var/run/docker.sock 1322 | - name: CORE_PEER_LOCALMSPID 1323 | value: Org3MSP 1324 | - name: CORE_PEER_MSPCONFIGPATH 1325 | value: /fabric/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/ 1326 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 1327 | value: "pbft" 1328 | - name: CORE_PBFT_GENERAL_MODE 1329 | value: "classic" 1330 | - name: CORE_PBFT_GENERAL_N 1331 | value: "4" 1332 | - name: CORE_LOGGING_LEVEL 1333 | value: debug 1334 | - name: CORE_LOGGING_PEER 1335 | value: debug 1336 | - name: CORE_LOGGING_CAUTHDSL 1337 | value: debug 1338 | - name: CORE_LOGGING_GOSSIP 1339 | value: debug 1340 | - name: CORE_LOGGING_LEDGER 1341 | value: debug 1342 | - name: CORE_LOGGING_MSP 1343 | value: debug 1344 | - name: CORE_LOGGING_POLICIES 1345 | value: debug 1346 | - name: CORE_LOGGING_GRPC 1347 | value: debug 1348 | - name: CORE_PEER_TLS_ENABLED 1349 | value: "false" 1350 | - name: CORE_LEDGER_STATE_STATEDATABASE 1351 | value: "CouchDB" 1352 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 1353 | value: "localhost:5984" 1354 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 1355 | value: "hyperledgeruser" 1356 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 1357 | value: "hyperledgerpass" 1358 | - name: FABRIC_CFG_PATH 1359 | value: /etc/hyperledger/fabric/ 1360 | - name: ORDERER_URL 1361 | value: blockchain-orderer:31010 1362 | - name: GODEBUG 1363 | value: "netdns=go" 1364 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 1365 | value: "true" 1366 | volumeMounts: 1367 | - mountPath: /fabric 1368 | name: fabricfiles 1369 | - mountPath: /host/var/run/docker.sock 1370 | name: dockersocket 1371 | - name: couchdb 1372 | image: hyperledger/fabric-couchdb:amd64-0.4.14 1373 | env: 1374 | - name: TZ 1375 | value: "America/Sao_Paulo" 1376 | - name: COUCHDB_USER 1377 | value: "hyperledgeruser" 1378 | - name: COUCHDB_PASSWORD 1379 | value: "hyperledgerpass" 1380 | ``` 1381 | *Note: The peer uses our shared filesystem.* 1382 | *Note: Because we're dealing with transactions, its important that every pod is running in the same timezone. Pay attention to the TZ environment variable.* 1383 | *Note: CORE_PEER_GOSSIP_BOOTSTRAP, CORE_PEER_GOSSIP_ENDPOINT and CORE_PEER_GOSSIP_EXTERNALENDPOINT are critical for the Hyperledger Fabric Service Discovery to work.* 1384 | *Note: Volume dockersocket is used in order for the peer to have access to the docker daemon running on the host the peer is running, to be able to launch the chaincode container* 1385 | *Note: The chaincode container will be launched directly into Docker Daemon, and will not show up in Kubernetes.* 1386 | *Note: There is a sidecar container running CouchDB. There are environment variables setting the peer to use this CouchDB instance.* 1387 | 1388 | - Create Org3MSP Peer2 Deployment 1389 | Create the file `kubernetes/blockchain-org3peer2_deploy.yaml` with the following `Deployment`: 1390 | ```yaml 1391 | apiVersion: extensions/v1beta1 1392 | kind: Deployment 1393 | metadata: 1394 | name: blockchain-org3peer2 1395 | spec: 1396 | replicas: 1 1397 | template: 1398 | metadata: 1399 | labels: 1400 | name: org3peer2 1401 | spec: 1402 | volumes: 1403 | - name: fabricfiles 1404 | persistentVolumeClaim: 1405 | claimName: fabric-pvc 1406 | - name: dockersocket 1407 | hostPath: 1408 | path: /var/run/docker.sock 1409 | 1410 | containers: 1411 | - name: peer 1412 | image: hyperledger/fabric-peer:amd64-1.3.0 1413 | command: ["sh", "-c", "peer node start"] 1414 | env: 1415 | - name: TZ 1416 | value: "America/Sao_Paulo" 1417 | - name: CORE_PEER_ADDRESSAUTODETECT 1418 | value: "true" 1419 | - name: CORE_PEER_ID 1420 | value: blockchain-org3peer2 1421 | - name: CORE_PEER_NETWORKID 1422 | value: nid1 1423 | - name: CORE_PEER_ADDRESS 1424 | value: blockchain-org3peer2:30110 1425 | - name: CORE_PEER_LISTENADDRESS 1426 | value: 0.0.0.0:30110 1427 | - name: CORE_PEER_EVENTS_ADDRESS 1428 | value: 0.0.0.0:30111 1429 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 1430 | value: blockchain-org3peer2:30110 1431 | - name: CORE_PEER_GOSSIP_ENDPOINT 1432 | value: blockchain-org3peer2:30110 1433 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 1434 | value: blockchain-org3peer2:30110 1435 | - name: CORE_PEER_GOSSIP_ORGLEADER 1436 | value: "false" 1437 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 1438 | value: "true" 1439 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 1440 | value: "true" 1441 | - name: CORE_PEER_COMMITTER_ENABLED 1442 | value: "false" 1443 | - name: CORE_PEER_PROFILE_ENABLED 1444 | value: "true" 1445 | - name: CORE_VM_ENDPOINT 1446 | value: unix:///host/var/run/docker.sock 1447 | - name: CORE_PEER_LOCALMSPID 1448 | value: Org3MSP 1449 | - name: CORE_PEER_MSPCONFIGPATH 1450 | value: /fabric/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/msp/ 1451 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 1452 | value: "pbft" 1453 | - name: CORE_PBFT_GENERAL_MODE 1454 | value: "classic" 1455 | - name: CORE_PBFT_GENERAL_N 1456 | value: "4" 1457 | - name: CORE_LOGGING_LEVEL 1458 | value: debug 1459 | - name: CORE_LOGGING_PEER 1460 | value: debug 1461 | - name: CORE_LOGGING_CAUTHDSL 1462 | value: debug 1463 | - name: CORE_LOGGING_GOSSIP 1464 | value: debug 1465 | - name: CORE_LOGGING_LEDGER 1466 | value: debug 1467 | - name: CORE_LOGGING_MSP 1468 | value: debug 1469 | - name: CORE_LOGGING_POLICIES 1470 | value: debug 1471 | - name: CORE_LOGGING_GRPC 1472 | value: debug 1473 | - name: CORE_PEER_TLS_ENABLED 1474 | value: "false" 1475 | - name: CORE_LEDGER_STATE_STATEDATABASE 1476 | value: "CouchDB" 1477 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 1478 | value: "localhost:5984" 1479 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 1480 | value: "hyperledgeruser" 1481 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 1482 | value: "hyperledgerpass" 1483 | - name: FABRIC_CFG_PATH 1484 | value: /etc/hyperledger/fabric/ 1485 | - name: ORDERER_URL 1486 | value: blockchain-orderer:31010 1487 | - name: GODEBUG 1488 | value: "netdns=go" 1489 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 1490 | value: "true" 1491 | volumeMounts: 1492 | - mountPath: /fabric 1493 | name: fabricfiles 1494 | - mountPath: /host/var/run/docker.sock 1495 | name: dockersocket 1496 | - name: couchdb 1497 | image: hyperledger/fabric-couchdb:amd64-0.4.14 1498 | env: 1499 | - name: TZ 1500 | value: "America/Sao_Paulo" 1501 | - name: COUCHDB_USER 1502 | value: "hyperledgeruser" 1503 | - name: COUCHDB_PASSWORD 1504 | value: "hyperledgerpass" 1505 | ``` 1506 | *Note: The peer uses our shared filesystem.* 1507 | *Note: Because we're dealing with transactions, its important that every pod is running in the same timezone. Pay attention to the TZ environment variable.* 1508 | *Note: CORE_PEER_GOSSIP_BOOTSTRAP, CORE_PEER_GOSSIP_ENDPOINT and CORE_PEER_GOSSIP_EXTERNALENDPOINT are critical for the Hyperledger Fabric Service Discovery to work.* 1509 | *Note: Volume dockersocket is used in order for the peer to have access to the docker daemon running on the host the peer is running, to be able to launch the chaincode container* 1510 | *Note: The chaincode container will be launched directly into Docker Daemon, and will not show up in Kubernetes.* 1511 | *Note: There is a sidecar container running CouchDB. There are environment variables setting the peer to use this CouchDB instance.* 1512 | 1513 | - Create Org3MSP Peer1 Service 1514 | Create the file `kubernetes/blockchain-org3peer1_svc.yaml` with the `Service` below: 1515 | ```yaml 1516 | apiVersion: v1 1517 | kind: Service 1518 | metadata: 1519 | name: blockchain-org3peer1 1520 | labels: 1521 | run: blockchain-org3peer1 1522 | spec: 1523 | type: ClusterIP 1524 | selector: 1525 | name: org3peer1 1526 | ports: 1527 | - protocol: TCP 1528 | port: 30110 1529 | name: grpc 1530 | - protocol: TCP 1531 | port: 30111 1532 | name: events 1533 | - protocol: TCP 1534 | port: 5984 1535 | name: couchdb 1536 | ``` 1537 | - Create Org3MSP Peer2 Service 1538 | Create the file `kubernetes/blockchain-org3peer2_svc.yaml` with `Service` below: 1539 | ```yaml 1540 | apiVersion: v1 1541 | kind: Service 1542 | metadata: 1543 | name: blockchain-org3peer2 1544 | labels: 1545 | run: blockchain-org3peer2 1546 | spec: 1547 | type: ClusterIP 1548 | selector: 1549 | name: org3peer2 1550 | ports: 1551 | - protocol: TCP 1552 | port: 30110 1553 | name: grpc 1554 | - protocol: TCP 1555 | port: 30111 1556 | name: events 1557 | - protocol: TCP 1558 | port: 5984 1559 | name: couchdb 1560 | ``` 1561 | - Apply Configuration 1562 | Now we're going to apply the previously created files: 1563 | ```sh 1564 | kubectl apply -f kubernetes/blockchain-org3peer1_deploy.yaml 1565 | kubectl apply -f kubernetes/blockchain-org3peer2_deploy.yaml 1566 | kubectl apply -f kubernetes/blockchain-org3peer1_svc.yaml 1567 | kubectl apply -f kubernetes/blockchain-org3peer2_svc.yaml 1568 | ``` 1569 | 1570 | ### Step 11: Org4MSP 1571 | 1572 | - Create Org4MSP Peer1 Deployment 1573 | Create the file `kubernetes/blockchain-org4peer1_deploy.yaml` the following `Deployment`: 1574 | ```yaml 1575 | apiVersion: extensions/v1beta1 1576 | kind: Deployment 1577 | metadata: 1578 | name: blockchain-org4peer1 1579 | spec: 1580 | replicas: 1 1581 | template: 1582 | metadata: 1583 | labels: 1584 | name: org4peer1 1585 | spec: 1586 | volumes: 1587 | - name: fabricfiles 1588 | persistentVolumeClaim: 1589 | claimName: fabric-pvc 1590 | - name: dockersocket 1591 | hostPath: 1592 | path: /var/run/docker.sock 1593 | 1594 | containers: 1595 | - name: peer 1596 | image: hyperledger/fabric-peer:amd64-1.3.0 1597 | command: ["sh", "-c", "peer node start"] 1598 | env: 1599 | - name: TZ 1600 | value: "America/Sao_Paulo" 1601 | - name: CORE_PEER_ADDRESSAUTODETECT 1602 | value: "true" 1603 | - name: CORE_PEER_ID 1604 | value: blockchain-org4peer1 1605 | - name: CORE_PEER_NETWORKID 1606 | value: nid1 1607 | - name: CORE_PEER_ADDRESS 1608 | value: blockchain-org4peer1:30110 1609 | - name: CORE_PEER_LISTENADDRESS 1610 | value: 0.0.0.0:30110 1611 | - name: CORE_PEER_EVENTS_ADDRESS 1612 | value: 0.0.0.0:30111 1613 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 1614 | value: blockchain-org4peer1:30110 1615 | - name: CORE_PEER_GOSSIP_ENDPOINT 1616 | value: blockchain-org4peer1:30110 1617 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 1618 | value: blockchain-org4peer1:30110 1619 | - name: CORE_PEER_GOSSIP_ORGLEADER 1620 | value: "false" 1621 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 1622 | value: "true" 1623 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 1624 | value: "false" 1625 | - name: CORE_PEER_COMMITTER_ENABLED 1626 | value: "true" 1627 | - name: CORE_PEER_PROFILE_ENABLED 1628 | value: "true" 1629 | - name: CORE_VM_ENDPOINT 1630 | value: unix:///host/var/run/docker.sock 1631 | - name: CORE_PEER_LOCALMSPID 1632 | value: Org4MSP 1633 | - name: CORE_PEER_MSPCONFIGPATH 1634 | value: /fabric/crypto-config/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp/ 1635 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 1636 | value: "pbft" 1637 | - name: CORE_PBFT_GENERAL_MODE 1638 | value: "classic" 1639 | - name: CORE_PBFT_GENERAL_N 1640 | value: "4" 1641 | - name: CORE_LOGGING_LEVEL 1642 | value: debug 1643 | - name: CORE_LOGGING_PEER 1644 | value: debug 1645 | - name: CORE_LOGGING_CAUTHDSL 1646 | value: debug 1647 | - name: CORE_LOGGING_GOSSIP 1648 | value: debug 1649 | - name: CORE_LOGGING_LEDGER 1650 | value: debug 1651 | - name: CORE_LOGGING_MSP 1652 | value: debug 1653 | - name: CORE_LOGGING_POLICIES 1654 | value: debug 1655 | - name: CORE_LOGGING_GRPC 1656 | value: debug 1657 | - name: CORE_PEER_TLS_ENABLED 1658 | value: "false" 1659 | - name: CORE_LEDGER_STATE_STATEDATABASE 1660 | value: "CouchDB" 1661 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 1662 | value: "localhost:5984" 1663 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 1664 | value: "hyperledgeruser" 1665 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 1666 | value: "hyperledgerpass" 1667 | - name: FABRIC_CFG_PATH 1668 | value: /etc/hyperledger/fabric/ 1669 | - name: ORDERER_URL 1670 | value: blockchain-orderer:31010 1671 | - name: GODEBUG 1672 | value: "netdns=go" 1673 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 1674 | value: "true" 1675 | volumeMounts: 1676 | - mountPath: /fabric 1677 | name: fabricfiles 1678 | - mountPath: /host/var/run/docker.sock 1679 | name: dockersocket 1680 | - name: couchdb 1681 | image: hyperledger/fabric-couchdb:amd64-0.4.14 1682 | env: 1683 | - name: TZ 1684 | value: "America/Sao_Paulo" 1685 | - name: COUCHDB_USER 1686 | value: "hyperledgeruser" 1687 | - name: COUCHDB_PASSWORD 1688 | value: "hyperledgerpass" 1689 | ``` 1690 | *Note: The peer uses our shared filesystem.* 1691 | *Note: Because we're dealing with transactions, its important that every pod is running in the same timezone. Pay attention to the TZ environment variable.* 1692 | *Note: CORE_PEER_GOSSIP_BOOTSTRAP, CORE_PEER_GOSSIP_ENDPOINT and CORE_PEER_GOSSIP_EXTERNALENDPOINT are critical for the Hyperledger Fabric Service Discovery to work.* 1693 | *Note: Volume dockersocket is used in order for the peer to have access to the docker daemon running on the host the peer is running, to be able to launch the chaincode container* 1694 | *Note: The chaincode container will be launched directly into Docker Daemon, and will not show up in Kubernetes.* 1695 | *Note: There is a sidecar container running CouchDB. There are environment variables setting the peer to use this CouchDB instance.* 1696 | 1697 | - Create Org4MSP Peer2 Deployment 1698 | Create the file `kubernetes/blockchain-org4peer2_deploy.yaml` with the following `Deployment`: 1699 | ```yaml 1700 | apiVersion: extensions/v1beta1 1701 | kind: Deployment 1702 | metadata: 1703 | name: blockchain-org4peer2 1704 | spec: 1705 | replicas: 1 1706 | template: 1707 | metadata: 1708 | labels: 1709 | name: org4peer2 1710 | spec: 1711 | volumes: 1712 | - name: fabricfiles 1713 | persistentVolumeClaim: 1714 | claimName: fabric-pvc 1715 | - name: dockersocket 1716 | hostPath: 1717 | path: /var/run/docker.sock 1718 | 1719 | containers: 1720 | - name: peer 1721 | image: hyperledger/fabric-peer:amd64-1.3.0 1722 | command: ["sh", "-c", "peer node start"] 1723 | env: 1724 | - name: TZ 1725 | value: "America/Sao_Paulo" 1726 | - name: CORE_PEER_ADDRESSAUTODETECT 1727 | value: "true" 1728 | - name: CORE_PEER_ID 1729 | value: blockchain-org4peer2 1730 | - name: CORE_PEER_NETWORKID 1731 | value: nid1 1732 | - name: CORE_PEER_ADDRESS 1733 | value: blockchain-org4peer2:30110 1734 | - name: CORE_PEER_LISTENADDRESS 1735 | value: 0.0.0.0:30110 1736 | - name: CORE_PEER_EVENTS_ADDRESS 1737 | value: 0.0.0.0:30111 1738 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 1739 | value: blockchain-org4peer2:30110 1740 | - name: CORE_PEER_GOSSIP_ENDPOINT 1741 | value: blockchain-org4peer2:30110 1742 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 1743 | value: blockchain-org4peer2:30110 1744 | - name: CORE_PEER_GOSSIP_ORGLEADER 1745 | value: "false" 1746 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 1747 | value: "true" 1748 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 1749 | value: "false" 1750 | - name: CORE_PEER_COMMITTER_ENABLED 1751 | value: "true" 1752 | - name: CORE_PEER_PROFILE_ENABLED 1753 | value: "true" 1754 | - name: CORE_VM_ENDPOINT 1755 | value: unix:///host/var/run/docker.sock 1756 | - name: CORE_PEER_LOCALMSPID 1757 | value: Org4MSP 1758 | - name: CORE_PEER_MSPCONFIGPATH 1759 | value: /fabric/crypto-config/peerOrganizations/org4.example.com/peers/peer1.org4.example.com/msp/ 1760 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 1761 | value: "pbft" 1762 | - name: CORE_PBFT_GENERAL_MODE 1763 | value: "classic" 1764 | - name: CORE_PBFT_GENERAL_N 1765 | value: "4" 1766 | - name: CORE_LOGGING_LEVEL 1767 | value: debug 1768 | - name: CORE_LOGGING_PEER 1769 | value: debug 1770 | - name: CORE_LOGGING_CAUTHDSL 1771 | value: debug 1772 | - name: CORE_LOGGING_GOSSIP 1773 | value: debug 1774 | - name: CORE_LOGGING_LEDGER 1775 | value: debug 1776 | - name: CORE_LOGGING_MSP 1777 | value: debug 1778 | - name: CORE_LOGGING_POLICIES 1779 | value: debug 1780 | - name: CORE_LOGGING_GRPC 1781 | value: debug 1782 | - name: CORE_PEER_TLS_ENABLED 1783 | value: "false" 1784 | - name: CORE_LEDGER_STATE_STATEDATABASE 1785 | value: "CouchDB" 1786 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 1787 | value: "localhost:5984" 1788 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 1789 | value: "hyperledgeruser" 1790 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 1791 | value: "hyperledgerpass" 1792 | - name: FABRIC_CFG_PATH 1793 | value: /etc/hyperledger/fabric/ 1794 | - name: ORDERER_URL 1795 | value: blockchain-orderer:31010 1796 | - name: GODEBUG 1797 | value: "netdns=go" 1798 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 1799 | value: "true" 1800 | volumeMounts: 1801 | - mountPath: /fabric 1802 | name: fabricfiles 1803 | - mountPath: /host/var/run/docker.sock 1804 | name: dockersocket 1805 | - name: couchdb 1806 | image: hyperledger/fabric-couchdb:amd64-0.4.14 1807 | env: 1808 | - name: TZ 1809 | value: "America/Sao_Paulo" 1810 | - name: COUCHDB_USER 1811 | value: "hyperledgeruser" 1812 | - name: COUCHDB_PASSWORD 1813 | value: "hyperledgerpass" 1814 | ``` 1815 | *Note: The peer uses our shared filesystem.* 1816 | *Note: Because we're dealing with transactions, its important that every pod is running in the same timezone. Pay attention to the TZ environment variable.* 1817 | *Note: CORE_PEER_GOSSIP_BOOTSTRAP, CORE_PEER_GOSSIP_ENDPOINT and CORE_PEER_GOSSIP_EXTERNALENDPOINT are critical for the Hyperledger Fabric Service Discovery to work.* 1818 | *Note: Volume dockersocket is used in order for the peer to have access to the docker daemon running on the host the peer is running, to be able to launch the chaincode container* 1819 | *Note: The chaincode container will be launched directly into Docker Daemon, and will not show up in Kubernetes.* 1820 | *Note: There is a sidecar container running CouchDB. There are environment variables setting the peer to use this CouchDB instance.* 1821 | 1822 | - Create Org4MSP Peer1 Service 1823 | Create the file `kubernetes/blockchain-org4peer1_svc.yaml` with the `Service` below: 1824 | ```yaml 1825 | apiVersion: v1 1826 | kind: Service 1827 | metadata: 1828 | name: blockchain-org4peer1 1829 | labels: 1830 | run: blockchain-org4peer1 1831 | spec: 1832 | type: ClusterIP 1833 | selector: 1834 | name: org4peer1 1835 | ports: 1836 | - protocol: TCP 1837 | port: 30110 1838 | name: grpc 1839 | - protocol: TCP 1840 | port: 30111 1841 | name: events 1842 | - protocol: TCP 1843 | port: 5984 1844 | name: couchdb 1845 | ``` 1846 | - Create Org4MSP Peer2 Service 1847 | Create the file `kubernetes/blockchain-org4peer2_svc.yaml` with the `Service` below: 1848 | ```yaml 1849 | apiVersion: v1 1850 | kind: Service 1851 | metadata: 1852 | name: blockchain-org4peer2 1853 | labels: 1854 | run: blockchain-org4peer2 1855 | spec: 1856 | type: ClusterIP 1857 | selector: 1858 | name: org4peer2 1859 | ports: 1860 | - protocol: TCP 1861 | port: 30110 1862 | name: grpc 1863 | - protocol: TCP 1864 | port: 30111 1865 | name: events 1866 | - protocol: TCP 1867 | port: 5984 1868 | name: couchdb 1869 | ``` 1870 | - Apply Configuration 1871 | Now we're going to apply the previously created files: 1872 | ```sh 1873 | kubectl apply -f kubernetes/blockchain-org4peer1_deploy.yaml 1874 | kubectl apply -f kubernetes/blockchain-org4peer2_deploy.yaml 1875 | kubectl apply -f kubernetes/blockchain-org4peer1_svc.yaml 1876 | kubectl apply -f kubernetes/blockchain-org4peer2_svc.yaml 1877 | ``` 1878 | 1879 | ### Step 12: Create Channel 1880 | Now its time to create our channel: 1881 | ```sh 1882 | kubectl exec -it fabric-tools -- /bin/bash 1883 | export CHANNEL_NAME="channel1" 1884 | cd /fabric 1885 | configtxgen -profile FourOrgsChannel -outputCreateChannelTx ${CHANNEL_NAME}.tx -channelID ${CHANNEL_NAME} 1886 | 1887 | export ORDERER_URL="blockchain-orderer:31010" 1888 | export CORE_PEER_ADDRESSAUTODETECT="false" 1889 | export CORE_PEER_NETWORKID="nid1" 1890 | export CORE_PEER_LOCALMSPID="Org1MSP" 1891 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/" 1892 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 1893 | peer channel create -o ${ORDERER_URL} -c ${CHANNEL_NAME} -f /fabric/${CHANNEL_NAME}.tx 1894 | exit 1895 | ``` 1896 | 1897 | ### Step 13: Join Channel 1898 | 1899 | - Org1MSP 1900 | Let's join Org1MSP to our channel: 1901 | ```sh 1902 | kubectl exec -it fabric-tools -- /bin/bash 1903 | export CHANNEL_NAME="channel1" 1904 | export CORE_PEER_NETWORKID="nid1" 1905 | export ORDERER_URL="blockchain-orderer:31010" 1906 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 1907 | export CORE_PEER_LOCALMSPID="Org1MSP" 1908 | export CORE_PEER_MSPID="Org1MSP" 1909 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" 1910 | 1911 | export CORE_PEER_ADDRESS="blockchain-org1peer1:30110" 1912 | peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} 1913 | peer channel join -b ${CHANNEL_NAME}_newest.block 1914 | 1915 | rm -rf /${CHANNEL_NAME}_newest.block 1916 | 1917 | export CORE_PEER_ADDRESS="blockchain-org1peer2:30110" 1918 | peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} 1919 | peer channel join -b ${CHANNEL_NAME}_newest.block 1920 | 1921 | rm -rf /${CHANNEL_NAME}_newest.block 1922 | exit 1923 | ``` 1924 | - Org2MSP 1925 | Let's join Org2MSP to our channel: 1926 | ```sh 1927 | kubectl exec -it fabric-tools -- /bin/bash 1928 | export CHANNEL_NAME="channel1" 1929 | export CORE_PEER_NETWORKID="nid1" 1930 | export ORDERER_URL="blockchain-orderer:31010" 1931 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 1932 | export CORE_PEER_LOCALMSPID="Org2MSP" 1933 | export CORE_PEER_MSPID="Org2MSP" 1934 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp" 1935 | 1936 | export CORE_PEER_ADDRESS="blockchain-org2peer1:30110" 1937 | peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} 1938 | peer channel join -b ${CHANNEL_NAME}_newest.block 1939 | 1940 | rm -rf /${CHANNEL_NAME}_newest.block 1941 | 1942 | export CORE_PEER_ADDRESS="blockchain-org2peer2:30110" 1943 | peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} 1944 | peer channel join -b ${CHANNEL_NAME}_newest.block 1945 | 1946 | rm -rf /${CHANNEL_NAME}_newest.block 1947 | exit 1948 | ``` 1949 | - Org3MSP 1950 | Let's join Org3MSP to our channel: 1951 | ```sh 1952 | kubectl exec -it fabric-tools -- /bin/bash 1953 | export CHANNEL_NAME="channel1" 1954 | export CORE_PEER_NETWORKID="nid1" 1955 | export ORDERER_URL="blockchain-orderer:31010" 1956 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 1957 | export CORE_PEER_LOCALMSPID="Org3MSP" 1958 | export CORE_PEER_MSPID="Org3MSP" 1959 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp" 1960 | 1961 | export CORE_PEER_ADDRESS="blockchain-org3peer1:30110" 1962 | peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} 1963 | peer channel join -b ${CHANNEL_NAME}_newest.block 1964 | 1965 | rm -rf /${CHANNEL_NAME}_newest.block 1966 | 1967 | export CORE_PEER_ADDRESS="blockchain-org3peer2:30110" 1968 | peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} 1969 | peer channel join -b ${CHANNEL_NAME}_newest.block 1970 | 1971 | rm -rf /${CHANNEL_NAME}_newest.block 1972 | exit 1973 | ``` 1974 | - Org4MSP 1975 | Let's join Org4MSP to our channel: 1976 | ```sh 1977 | kubectl exec -it fabric-tools -- /bin/bash 1978 | export CHANNEL_NAME="channel1" 1979 | export CORE_PEER_NETWORKID="nid1" 1980 | export ORDERER_URL="blockchain-orderer:31010" 1981 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 1982 | export CORE_PEER_LOCALMSPID="Org4MSP" 1983 | export CORE_PEER_MSPID="Org4MSP" 1984 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp" 1985 | 1986 | export CORE_PEER_ADDRESS="blockchain-org4peer1:30110" 1987 | peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} 1988 | peer channel join -b ${CHANNEL_NAME}_newest.block 1989 | 1990 | rm -rf /${CHANNEL_NAME}_newest.block 1991 | 1992 | export CORE_PEER_ADDRESS="blockchain-org4peer2:30110" 1993 | peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} 1994 | peer channel join -b ${CHANNEL_NAME}_newest.block 1995 | 1996 | rm -rf /${CHANNEL_NAME}_newest.block 1997 | exit 1998 | ``` 1999 | 2000 | ### Step 14: Install Chaincode 2001 | 2002 | - Org1MSP 2003 | Let's install our chaincode on Org1MSP Peers: 2004 | ```sh 2005 | kubectl exec -it fabric-tools -- /bin/bash 2006 | cp -r /fabric/config/chaincode $GOPATH/src/ 2007 | export CHAINCODE_NAME="cc" 2008 | export CHAINCODE_VERSION="1.0" 2009 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 2010 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" 2011 | export CORE_PEER_LOCALMSPID="Org1MSP" 2012 | 2013 | export CORE_PEER_ADDRESS="blockchain-org1peer1:30110" 2014 | peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/ 2015 | 2016 | export CORE_PEER_ADDRESS="blockchain-org1peer2:30110" 2017 | peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/ 2018 | 2019 | exit 2020 | ``` 2021 | - Org2MSP 2022 | Let's install our chaincode on Org2MSP Peers: 2023 | ```sh 2024 | kubectl exec -it fabric-tools -- /bin/bash 2025 | cp -r /fabric/config/chaincode $GOPATH/src/ 2026 | export CHAINCODE_NAME="cc" 2027 | export CHAINCODE_VERSION="1.0" 2028 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 2029 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp" 2030 | export CORE_PEER_LOCALMSPID="Org2MSP" 2031 | 2032 | export CORE_PEER_ADDRESS="blockchain-org2peer1:30110" 2033 | peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/ 2034 | 2035 | export CORE_PEER_ADDRESS="blockchain-org2peer2:30110" 2036 | peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/ 2037 | 2038 | exit 2039 | ``` 2040 | - Org3MSP 2041 | Let's install our chaincode on Org3MSP Peers: 2042 | ```sh 2043 | kubectl exec -it fabric-tools -- /bin/bash 2044 | cp -r /fabric/config/chaincode $GOPATH/src/ 2045 | export CHAINCODE_NAME="cc" 2046 | export CHAINCODE_VERSION="1.0" 2047 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 2048 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp" 2049 | export CORE_PEER_LOCALMSPID="Org3MSP" 2050 | 2051 | export CORE_PEER_ADDRESS="blockchain-org3peer1:30110" 2052 | peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/ 2053 | 2054 | export CORE_PEER_ADDRESS="blockchain-org3peer2:30110" 2055 | peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/ 2056 | 2057 | exit 2058 | ``` 2059 | - Org4MSP 2060 | Let's install our chaincode on Org4MSP Peers: 2061 | ```sh 2062 | kubectl exec -it fabric-tools -- /bin/bash 2063 | cp -r /fabric/config/chaincode $GOPATH/src/ 2064 | export CHAINCODE_NAME="cc" 2065 | export CHAINCODE_VERSION="1.0" 2066 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 2067 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp" 2068 | export CORE_PEER_LOCALMSPID="Org4MSP" 2069 | 2070 | export CORE_PEER_ADDRESS="blockchain-org4peer1:30110" 2071 | peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/ 2072 | 2073 | export CORE_PEER_ADDRESS="blockchain-org4peer2:30110" 2074 | peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/ 2075 | 2076 | exit 2077 | ``` 2078 | 2079 | ### Step 15: Instantiate Chaincode 2080 | 2081 | Now its time to instantiate our chaincode: 2082 | ```sh 2083 | kubectl exec -it fabric-tools -- /bin/bash 2084 | export CHANNEL_NAME="channel1" 2085 | export CHAINCODE_NAME="cc" 2086 | export CHAINCODE_VERSION="1.0" 2087 | export FABRIC_CFG_PATH="/etc/hyperledger/fabric" 2088 | export CORE_PEER_MSPCONFIGPATH="/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" 2089 | export CORE_PEER_LOCALMSPID="Org1MSP" 2090 | export CORE_PEER_ADDRESS="blockchain-org1peer1:30110" 2091 | export ORDERER_URL="blockchain-orderer:31010" 2092 | 2093 | peer chaincode instantiate -o ${ORDERER_URL} -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -P "AND('Org1MSP.member','Org2MSP.member','Org3MSP.member','Org4MSP.member')" -c '{"Args":["init","a","300","b","600"]}' 2094 | exit 2095 | ``` 2096 | *Note: The policy -P is set using AND. This will set the policy in a way that at least 1 peer from each Org will need to endorse the transaction.* 2097 | *Note: Because of this policy, every transaction sent to the network will have to be sent to at least 1 peer from each organization.* 2098 | *Note: As we're using Balance Transfer example, we're starting A with 300 and B with 600.* 2099 | 2100 | ### Step 16: AnchorPeers 2101 | 2102 | Now we need to update our channel configuration to reflect our Anchor Peers: 2103 | ```sh 2104 | pod=$(kubectl get pods | grep blockchain-org1peer1 | awk '{print $1}') 2105 | kubectl exec -it $pod -- peer channel update -f /fabric/Org1MSPanchors.tx -c channel1 -o blockchain-orderer:31010 2106 | 2107 | pod=$(kubectl get pods | grep blockchain-org2peer1 | awk '{print $1}') 2108 | kubectl exec -it $pod -- peer channel update -f /fabric/Org2MSPanchors.tx -c channel1 -o blockchain-orderer:31010 2109 | 2110 | pod=$(kubectl get pods | grep blockchain-org3peer1 | awk '{print $1}') 2111 | kubectl exec -it $pod -- peer channel update -f /fabric/Org3MSPanchors.tx -c channel1 -o blockchain-orderer:31010 2112 | 2113 | pod=$(kubectl get pods | grep blockchain-org4peer1 | awk '{print $1}') 2114 | kubectl exec -it $pod -- peer channel update -f /fabric/Org4MSPanchors.tx -c channel1 -o blockchain-orderer:31010 2115 | ``` 2116 | *Note: This step is very important for the Hyperledger Fabric Service Discovery to work properly.* 2117 | *Note: For each organization we only need to execute the peer channel update once.* 2118 | *Note: The command is executed on a peer that is on the same Organization as the Anchor file.* 2119 | 2120 | ### Step 17: Deploy Hyperledger Explorer 2121 | 2122 | Fabric Explorer needs a PostgreSQL Database as its backend. In order to deploy, we'll create the file `kubernetes/blockchain-explorer-db_deploy.yaml` with the following `Deployment`: 2123 | ```yaml 2124 | apiVersion: extensions/v1beta1 2125 | kind: Deployment 2126 | metadata: 2127 | name: blockchain-explorer-db 2128 | spec: 2129 | replicas: 1 2130 | template: 2131 | metadata: 2132 | labels: 2133 | name: explorer-db 2134 | spec: 2135 | volumes: 2136 | - name: fabricfiles 2137 | persistentVolumeClaim: 2138 | claimName: fabric-pvc 2139 | 2140 | containers: 2141 | - name: postgres 2142 | image: postgres:10.4-alpine 2143 | env: 2144 | - name: TZ 2145 | value: "America/Sao_Paulo" 2146 | - name: DATABASE_DATABASE 2147 | value: fabricexplorer 2148 | - name: DATABASE_USERNAME 2149 | value: hppoc 2150 | - name: DATABASE_PASSWORD 2151 | value: password 2152 | volumeMounts: 2153 | - mountPath: /fabric 2154 | name: fabricfiles 2155 | ``` 2156 | *Note: The timezone is also important here.* 2157 | *Note: This pod will need Internet access.* 2158 | 2159 | Now we're going to apply the configuration: 2160 | ```sh 2161 | kubectl apply -f kubernetes/blockchain-explorer-db_deploy.yaml 2162 | ``` 2163 | 2164 | After that, we need to create the `Service` entry for our database. To do that let's create the file `kubernetes/blockchain-explorer-db_svc.yaml` as below: 2165 | ```yaml 2166 | apiVersion: v1 2167 | kind: Service 2168 | metadata: 2169 | name: blockchain-explorer-db 2170 | labels: 2171 | run: explorer-db 2172 | spec: 2173 | type: ClusterIP 2174 | selector: 2175 | name: explorer-db 2176 | ports: 2177 | - protocol: TCP 2178 | port: 5432 2179 | targetPort: 5432 2180 | name: pgsql 2181 | ``` 2182 | 2183 | Now we're going to apply the configuration: 2184 | ```sh 2185 | kubectl apply -f kubernetes/blockchain-explorer-db_svc.yaml 2186 | ``` 2187 | 2188 | Now, before proceeding, make sure the PostgreSQL Pod is running. We need to create the tables and artifacts for Hyperledger Explorer in our database: 2189 | ```sh 2190 | pod=$(kubectl get pods | grep blockchain-explorer-db | awk '{print $1}') 2191 | kubectl exec -it $pod -- /bin/bash 2192 | mkdir -p /fabric/config/explorer/db/ 2193 | mkdir -p /fabric/config/explorer/app/ 2194 | cd /fabric/config/explorer/db/ 2195 | wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/createdb.sh 2196 | wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/explorerpg.sql 2197 | wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/processenv.js 2198 | wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/updatepg.sql 2199 | apk update 2200 | apk add jq 2201 | apk add nodejs 2202 | apk add sudo 2203 | rm -rf /var/cache/apk/* 2204 | chmod +x ./createdb.sh 2205 | ./createdb.sh 2206 | exit 2207 | ``` 2208 | Now, we're going to create the config file with our Hyperledger Network description to use on Hyperledger Explorer. In order to do that, we'll create the file `config/explorer/app/config.json` with the following configuration: 2209 | ```json 2210 | { 2211 | "network-configs": { 2212 | "network-1": { 2213 | "version": "1.0", 2214 | "clients": { 2215 | "client-1": { 2216 | "tlsEnable": false, 2217 | "organization": "Org1MSP", 2218 | "channel": "channel1", 2219 | "credentialStore": { 2220 | "path": "./tmp/credentialStore_Org1/credential", 2221 | "cryptoStore": { 2222 | "path": "./tmp/credentialStore_Org1/crypto" 2223 | } 2224 | } 2225 | } 2226 | }, 2227 | "channels": { 2228 | "channel1": { 2229 | "peers": { 2230 | "blockchain-org1peer1": {}, 2231 | "blockchain-org2peer1": {}, 2232 | "blockchain-org3peer1": {}, 2233 | "blockchain-org4peer1": {}, 2234 | "blockchain-org1peer2": {}, 2235 | "blockchain-org2peer2": {}, 2236 | "blockchain-org3peer2": {}, 2237 | "blockchain-org4peer2": {} 2238 | }, 2239 | "orderers": { 2240 | "blockchain-orderer" : {} 2241 | }, 2242 | "connection": { 2243 | "timeout": { 2244 | "peer": { 2245 | "endorser": "6000", 2246 | "eventHub": "6000", 2247 | "eventReg": "6000" 2248 | } 2249 | } 2250 | } 2251 | } 2252 | }, 2253 | "organizations": { 2254 | "Org1MSP": { 2255 | "mspid": "Org1MSP", 2256 | "fullpath": false, 2257 | "adminPrivateKey": { 2258 | "path": 2259 | "/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore" 2260 | }, 2261 | "signedCert": { 2262 | "path": 2263 | "/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts" 2264 | } 2265 | }, 2266 | "Org2MSP": { 2267 | "mspid": "Org2MSP", 2268 | "fullpath": false, 2269 | "adminPrivateKey": { 2270 | "path": 2271 | "/fabric/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore" 2272 | }, 2273 | "signedCert": { 2274 | "path": 2275 | "/fabric/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts" 2276 | } 2277 | }, 2278 | "Org3MSP": { 2279 | "mspid": "Org3MSP", 2280 | "fullpath": false, 2281 | "adminPrivateKey": { 2282 | "path": 2283 | "/fabric/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/keystore" 2284 | }, 2285 | "signedCert": { 2286 | "path": 2287 | "/fabric/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/signcerts" 2288 | } 2289 | }, 2290 | "Org4MSP": { 2291 | "mspid": "Org4MSP", 2292 | "fullpath": false, 2293 | "adminPrivateKey": { 2294 | "path": 2295 | "/fabric/crypto-config/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp/keystore" 2296 | }, 2297 | "signedCert": { 2298 | "path": 2299 | "/fabric/crypto-config/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp/signcerts" 2300 | } 2301 | }, 2302 | "OrdererMSP": { 2303 | "mspid": "OrdererMSP", 2304 | "adminPrivateKey": { 2305 | "path": 2306 | "/fabric/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore" 2307 | } 2308 | } 2309 | }, 2310 | "peers": { 2311 | "blockchain-org1peer1": { 2312 | "tlsCACerts": { 2313 | "path": 2314 | "/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" 2315 | }, 2316 | "url": "grpc://blockchain-org1peer1:30110", 2317 | "eventUrl": "grpc://blockchain-org1peer1:30111", 2318 | "grpcOptions": { 2319 | "ssl-target-name-override": "peer0.org1.example.com" 2320 | } 2321 | }, 2322 | "blockchain-org2peer1": { 2323 | "tlsCACerts": { 2324 | "path": 2325 | "/fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" 2326 | }, 2327 | "url": "grpc://blockchain-org2peer1:30110", 2328 | "eventUrl": "grpc://blockchain-org2peer1:30111", 2329 | "grpcOptions": { 2330 | "ssl-target-name-override": "peer0.org2.example.com" 2331 | } 2332 | }, 2333 | "blockchain-org3peer1": { 2334 | "tlsCACerts": { 2335 | "path": 2336 | "/fabric/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt" 2337 | }, 2338 | "url": "grpc://blockchain-org3peer1:30110", 2339 | "eventUrl": "grpc://blockchain-org3peer1:30111", 2340 | "grpcOptions": { 2341 | "ssl-target-name-override": "peer0.org3.example.com" 2342 | } 2343 | }, 2344 | "blockchain-org4peer1": { 2345 | "tlsCACerts": { 2346 | "path": 2347 | "/fabric/crypto-config/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/ca.crt" 2348 | }, 2349 | "url": "grpc://blockchain-org4peer1:30110", 2350 | "eventUrl": "grpc://blockchain-org4peer1:30111", 2351 | "grpcOptions": { 2352 | "ssl-target-name-override": "peer0.org4.example.com" 2353 | } 2354 | }, 2355 | "blockchain-org1peer2": { 2356 | "tlsCACerts": { 2357 | "path": 2358 | "/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt" 2359 | }, 2360 | "url": "grpc://blockchain-org1peer2:30110", 2361 | "eventUrl": "grpc://blockchain-org1peer2:30111", 2362 | "grpcOptions": { 2363 | "ssl-target-name-override": "peer1.org1.example.com" 2364 | } 2365 | }, 2366 | "blockchain-org2peer2": { 2367 | "tlsCACerts": { 2368 | "path": 2369 | "/fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt" 2370 | }, 2371 | "url": "grpc://blockchain-org2peer2:30110", 2372 | "eventUrl": "grpc://blockchain-org2peer2:30111", 2373 | "grpcOptions": { 2374 | "ssl-target-name-override": "peer1.org2.example.com" 2375 | } 2376 | }, 2377 | "blockchain-org3peer2": { 2378 | "tlsCACerts": { 2379 | "path": 2380 | "/fabric/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls/ca.crt" 2381 | }, 2382 | "url": "grpc://blockchain-org3peer2:30110", 2383 | "eventUrl": "grpc://blockchain-org3peer2:30111", 2384 | "grpcOptions": { 2385 | "ssl-target-name-override": "peer1.org3.example.com" 2386 | } 2387 | }, 2388 | "blockchain-org4peer2": { 2389 | "tlsCACerts": { 2390 | "path": 2391 | "/fabric/crypto-config/peerOrganizations/org4.example.com/peers/peer1.org4.example.com/tls/ca.crt" 2392 | }, 2393 | "url": "grpc://blockchain-org4peer2:30110", 2394 | "eventUrl": "grpc://blockchain-org4peer2:30111", 2395 | "grpcOptions": { 2396 | "ssl-target-name-override": "peer1.org4.example.com" 2397 | } 2398 | } 2399 | }, 2400 | "orderers": { 2401 | "blockchain-orderer": { 2402 | "url": "grpc://blockchain-orderer:31010" 2403 | } 2404 | } 2405 | } 2406 | }, 2407 | "configtxgenToolPath": "/fabric-path/workspace/fabric-samples/bin", 2408 | "license": "Apache-2.0" 2409 | } 2410 | ``` 2411 | 2412 | After creating the file, its time to copy it to our shared filesystem: 2413 | ```sh 2414 | kubectl cp config/explorer/app/config.json fabric-tools:/fabric/config/explorer/app/ 2415 | ``` 2416 | 2417 | Create the `config/explorer/app/run.sh` as below: 2418 | ```sh 2419 | #!/bin/sh 2420 | mkdir -p /opt/explorer/app/platform/fabric/ 2421 | mkdir -p /tmp/ 2422 | 2423 | mv /opt/explorer/app/platform/fabric/config.json /opt/explorer/app/platform/fabric/config.json.vanilla 2424 | cp /fabric/config/explorer/app/config.json /opt/explorer/app/platform/fabric/config.json 2425 | 2426 | cd /opt/explorer 2427 | node $EXPLORER_APP_PATH/main.js && tail -f /dev/null 2428 | ``` 2429 | 2430 | After creating the file, its time to copy it to our shared filesystem: 2431 | ```sh 2432 | chmod +x config/explorer/app/run.sh 2433 | kubectl cp config/explorer/app/run.sh fabric-tools:/fabric/config/explorer/app/ 2434 | ``` 2435 | 2436 | Now its time to create our Hyperledger Explorer application `Deployment` by creating the file `kubernetes/blockchain-explorer-app_deploy.yaml` as below: 2437 | ```yaml 2438 | apiVersion: extensions/v1beta1 2439 | kind: Deployment 2440 | metadata: 2441 | name: blockchain-explorer-app 2442 | spec: 2443 | replicas: 1 2444 | template: 2445 | metadata: 2446 | labels: 2447 | name: explorer 2448 | spec: 2449 | volumes: 2450 | - name: fabricfiles 2451 | persistentVolumeClaim: 2452 | claimName: fabric-pvc 2453 | 2454 | containers: 2455 | - name: explorer 2456 | image: hyperledger/explorer:latest 2457 | command: ["sh" , "-c" , "/fabric/config/explorer/app/run.sh"] 2458 | env: 2459 | - name: TZ 2460 | value: "America/Sao_Paulo" 2461 | - name: DATABASE_HOST 2462 | value: blockchain-explorer-db 2463 | - name: DATABASE_USERNAME 2464 | value: hppoc 2465 | - name: DATABASE_PASSWORD 2466 | value: password 2467 | volumeMounts: 2468 | - mountPath: /fabric 2469 | name: fabricfiles 2470 | ``` 2471 | *Note: Again setting up the timezone as the reports might get impacted.* 2472 | *Note: This deployment will have access to the shared filesystem as the startup script and config files are store there.* 2473 | *Note: There are 3 environment variables here pointing our application to the previously created PostgreSQL service.* 2474 | 2475 | Now its time to apply our `Deployment`: 2476 | ```sh 2477 | kubectl apply -f kubernetes/blockchain-explorer-app_deploy.yaml 2478 | ``` 2479 | 2480 | ## CLEANUP 2481 | 2482 | Now, to leave our environment clean, we're going to remove our helper `Pod`: 2483 | ```sh 2484 | kubectl delete -f kubernetes/fabric-tools.yaml 2485 | ``` 2486 | 2487 | ## VALIDATING 2488 | 2489 | Now, we're going to run 2 transactions. The first one we'll move 50 from `A` to `B`. The second one we'll move 33 from `B` to `A`: 2490 | ```sh 2491 | pod=$(kubectl get pods | grep blockchain-org1peer1 | awk '{print $1}') 2492 | kubectl exec -it $pod -- /bin/bash 2493 | 2494 | peer chaincode invoke --peerAddresses blockchain-org1peer1:30110 --peerAddresses blockchain-org2peer1:30110 --peerAddresses blockchain-org3peer1:30110 --peerAddresses blockchain-org4peer1:30110 -o blockchain-orderer:31010 -C channel1 -n cc -c '{"Args":["invoke","a","b","50"]}' 2495 | 2496 | peer chaincode invoke --peerAddresses blockchain-org1peer1:30110 --peerAddresses blockchain-org2peer1:30110 --peerAddresses blockchain-org3peer1:30110 --peerAddresses blockchain-org4peer1:30110 -o blockchain-orderer:31010 -C channel1 -n cc -c '{"Args":["invoke","b","a","33"]}' 2497 | 2498 | exit 2499 | ``` 2500 | *Note: The invoke command is using --peerAddresses parameter four times, in order to send the transaction to at least one peer from each organization.* 2501 | *Note: The first transaction might take a little bit to go through.* 2502 | *Note: We're executing transaction on Org1MSP Peer1.* 2503 | 2504 | Now we're going to check our balance. As stated before, we've started `A` with 300 and `B` with 600: 2505 | ```sh 2506 | pod=$(kubectl get pods | grep blockchain-org1peer1 | awk '{print $1}') 2507 | kubectl exec -it $pod -- /bin/bash 2508 | 2509 | peer chaincode query -C channel1 -n cc -c '{"Args":["query","a"]}' 2510 | 2511 | peer chaincode query -C channel1 -n cc -c '{"Args":["query","b"]}' 2512 | 2513 | exit 2514 | ``` 2515 | *Note: A should return 283 and B should return 617.* 2516 | *Note: We're executing transaction on Org1MSP Peer1.* 2517 | 2518 | We can also check the network status as well as the transactions on Hyperledger Explorer: 2519 | ```sh 2520 | pod=$(kubectl get pods | grep blockchain-explorer-app | awk '{print $1}') 2521 | kubectl port-forward $pod 8080:8080 2522 | ``` 2523 | 2524 | Now open your browser to [http://127.0.0.1:8080/](http://127.0.0.1:8080/). 2525 | In the first window you can see your network status and transactions as below: 2526 | 2527 | ![slide6.jpg](https://github.com/feitnomore/hyperledger-fabric-kubernetes/raw/master/images/slide6.jpg) 2528 | 2529 | You can also click on transactions tab, and check for a transaction as below: 2530 | 2531 | ![slide7.jpg](https://github.com/feitnomore/hyperledger-fabric-kubernetes/raw/master/images/slide7.jpg) 2532 | 2533 | *Note: You can see here that the transaction got endorsed by all the 4 Organizations.* 2534 | 2535 | ## Reference Links 2536 | 2537 | * [Hyperledger Fabric](https://hyperledger-fabric.readthedocs.io/en/release-1.3/) 2538 | * [Hyperledger Explorer](https://www.hyperledger.org/projects/explorer) 2539 | * [Apache CouchDB](http://couchdb.apache.org/) 2540 | * [Apache Kafka](https://kafka.apache.org/) 2541 | * [Kubernetes Concepts](https://kubernetes.io/docs/concepts/) 2542 | -------------------------------------------------------------------------------- /config/chaincode/chaincode_example02/chaincode_example02.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright IBM Corp. 2016 All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | //WARNING - this chaincode's ID is hard-coded in chaincode_example04 to illustrate one way of 20 | //calling chaincode from a chaincode. If this example is modified, chaincode_example04.go has 21 | //to be modified as well with the new ID of chaincode_example02. 22 | //chaincode_example05 show's how chaincode ID can be passed in as a parameter instead of 23 | //hard-coding. 24 | 25 | import ( 26 | "fmt" 27 | "strconv" 28 | 29 | "github.com/hyperledger/fabric-chaincode-go/shim" 30 | sc "github.com/hyperledger/fabric-protos-go/peer" 31 | ) 32 | 33 | // SimpleChaincode example simple Chaincode implementation 34 | type SimpleChaincode struct { 35 | } 36 | 37 | func (t *SimpleChaincode) Init(stub shim.ChaincodeStubInterface) pb.Response { 38 | fmt.Println("ex02 Init") 39 | _, args := stub.GetFunctionAndParameters() 40 | var A, B string // Entities 41 | var Aval, Bval int // Asset holdings 42 | var err error 43 | 44 | if len(args) != 4 { 45 | return shim.Error("Incorrect number of arguments. Expecting 4") 46 | } 47 | 48 | // Initialize the chaincode 49 | A = args[0] 50 | Aval, err = strconv.Atoi(args[1]) 51 | if err != nil { 52 | return shim.Error("Expecting integer value for asset holding") 53 | } 54 | B = args[2] 55 | Bval, err = strconv.Atoi(args[3]) 56 | if err != nil { 57 | return shim.Error("Expecting integer value for asset holding") 58 | } 59 | fmt.Printf("Aval = %d, Bval = %d\n", Aval, Bval) 60 | 61 | // Write the state to the ledger 62 | err = stub.PutState(A, []byte(strconv.Itoa(Aval))) 63 | if err != nil { 64 | return shim.Error(err.Error()) 65 | } 66 | 67 | err = stub.PutState(B, []byte(strconv.Itoa(Bval))) 68 | if err != nil { 69 | return shim.Error(err.Error()) 70 | } 71 | 72 | return shim.Success(nil) 73 | } 74 | 75 | func (t *SimpleChaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response { 76 | fmt.Println("ex02 Invoke") 77 | function, args := stub.GetFunctionAndParameters() 78 | if function == "invoke" { 79 | // Make payment of X units from A to B 80 | return t.invoke(stub, args) 81 | } else if function == "delete" { 82 | // Deletes an entity from its state 83 | return t.delete(stub, args) 84 | } else if function == "query" { 85 | // the old "Query" is now implemtned in invoke 86 | return t.query(stub, args) 87 | } 88 | 89 | return shim.Error("Invalid invoke function name. Expecting \"invoke\" \"delete\" \"query\"") 90 | } 91 | 92 | // Transaction makes payment of X units from A to B 93 | func (t *SimpleChaincode) invoke(stub shim.ChaincodeStubInterface, args []string) pb.Response { 94 | var A, B string // Entities 95 | var Aval, Bval int // Asset holdings 96 | var X int // Transaction value 97 | var err error 98 | 99 | if len(args) != 3 { 100 | return shim.Error("Incorrect number of arguments. Expecting 3") 101 | } 102 | 103 | A = args[0] 104 | B = args[1] 105 | 106 | // Get the state from the ledger 107 | // TODO: will be nice to have a GetAllState call to ledger 108 | Avalbytes, err := stub.GetState(A) 109 | if err != nil { 110 | return shim.Error("Failed to get state") 111 | } 112 | if Avalbytes == nil { 113 | return shim.Error("Entity not found") 114 | } 115 | Aval, _ = strconv.Atoi(string(Avalbytes)) 116 | 117 | Bvalbytes, err := stub.GetState(B) 118 | if err != nil { 119 | return shim.Error("Failed to get state") 120 | } 121 | if Bvalbytes == nil { 122 | return shim.Error("Entity not found") 123 | } 124 | Bval, _ = strconv.Atoi(string(Bvalbytes)) 125 | 126 | // Perform the execution 127 | X, err = strconv.Atoi(args[2]) 128 | if err != nil { 129 | return shim.Error("Invalid transaction amount, expecting a integer value") 130 | } 131 | Aval = Aval - X 132 | Bval = Bval + X 133 | fmt.Printf("Aval = %d, Bval = %d\n", Aval, Bval) 134 | 135 | // Write the state back to the ledger 136 | err = stub.PutState(A, []byte(strconv.Itoa(Aval))) 137 | if err != nil { 138 | return shim.Error(err.Error()) 139 | } 140 | 141 | err = stub.PutState(B, []byte(strconv.Itoa(Bval))) 142 | if err != nil { 143 | return shim.Error(err.Error()) 144 | } 145 | 146 | return shim.Success(nil) 147 | } 148 | 149 | // Deletes an entity from state 150 | func (t *SimpleChaincode) delete(stub shim.ChaincodeStubInterface, args []string) pb.Response { 151 | if len(args) != 1 { 152 | return shim.Error("Incorrect number of arguments. Expecting 1") 153 | } 154 | 155 | A := args[0] 156 | 157 | // Delete the key from the state in ledger 158 | err := stub.DelState(A) 159 | if err != nil { 160 | return shim.Error("Failed to delete state") 161 | } 162 | 163 | return shim.Success(nil) 164 | } 165 | 166 | // query callback representing the query of a chaincode 167 | func (t *SimpleChaincode) query(stub shim.ChaincodeStubInterface, args []string) pb.Response { 168 | var A string // Entities 169 | var err error 170 | 171 | if len(args) != 1 { 172 | return shim.Error("Incorrect number of arguments. Expecting name of the person to query") 173 | } 174 | 175 | A = args[0] 176 | 177 | // Get the state from the ledger 178 | Avalbytes, err := stub.GetState(A) 179 | if err != nil { 180 | jsonResp := "{\"Error\":\"Failed to get state for " + A + "\"}" 181 | return shim.Error(jsonResp) 182 | } 183 | 184 | if Avalbytes == nil { 185 | jsonResp := "{\"Error\":\"Nil amount for " + A + "\"}" 186 | return shim.Error(jsonResp) 187 | } 188 | 189 | jsonResp := "{\"Name\":\"" + A + "\",\"Amount\":\"" + string(Avalbytes) + "\"}" 190 | fmt.Printf("Query Response:%s\n", jsonResp) 191 | return shim.Success(Avalbytes) 192 | } 193 | 194 | func main() { 195 | err := shim.Start(new(SimpleChaincode)) 196 | if err != nil { 197 | fmt.Printf("Error starting Simple chaincode: %s", err) 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /config/configtx.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | Organizations: 3 | 4 | - &OrdererOrg 5 | Name: OrdererOrg 6 | ID: OrdererMSP 7 | MSPDir: crypto-config/ordererOrganizations/example.com/msp 8 | AdminPrincipal: Role.MEMBER 9 | 10 | - &Org1 11 | Name: Org1MSP 12 | ID: Org1MSP 13 | MSPDir: crypto-config/peerOrganizations/org1.example.com/msp 14 | AdminPrincipal: Role.MEMBER 15 | AnchorPeers: 16 | - Host: blockchain-org1peer1 17 | Port: 30110 18 | - Host: blockchain-org1peer2 19 | Port: 30110 20 | 21 | - &Org2 22 | Name: Org2MSP 23 | ID: Org2MSP 24 | MSPDir: crypto-config/peerOrganizations/org2.example.com/msp 25 | AdminPrincipal: Role.MEMBER 26 | AnchorPeers: 27 | - Host: blockchain-org2peer1 28 | Port: 30110 29 | - Host: blockchain-org2peer2 30 | Port: 30110 31 | 32 | - &Org3 33 | Name: Org3MSP 34 | ID: Org3MSP 35 | MSPDir: crypto-config/peerOrganizations/org3.example.com/msp 36 | AdminPrincipal: Role.MEMBER 37 | AnchorPeers: 38 | - Host: blockchain-org3peer1 39 | Port: 30110 40 | - Host: blockchain-org3peer2 41 | Port: 30110 42 | 43 | - &Org4 44 | Name: Org4MSP 45 | ID: Org4MSP 46 | MSPDir: crypto-config/peerOrganizations/org4.example.com/msp 47 | AdminPrincipal: Role.MEMBER 48 | AnchorPeers: 49 | - Host: blockchain-org4peer1 50 | Port: 30110 51 | - Host: blockchain-org4peer2 52 | Port: 30110 53 | 54 | Orderer: &OrdererDefaults 55 | 56 | OrdererType: kafka 57 | Addresses: 58 | - blockchain-orderer:31010 59 | 60 | BatchTimeout: 1s 61 | BatchSize: 62 | MaxMessageCount: 50 63 | AbsoluteMaxBytes: 99 MB 64 | PreferredMaxBytes: 512 KB 65 | 66 | Kafka: 67 | Brokers: 68 | - kafka1.local.parisi.biz:9092 69 | - kafka2.local.parisi.biz:9092 70 | - kafka3.local.parisi.biz:9092 71 | - kafka4.local.parisi.biz:9092 72 | 73 | Organizations: 74 | 75 | Application: &ApplicationDefaults 76 | 77 | Organizations: 78 | 79 | Profiles: 80 | 81 | FourOrgsOrdererGenesis: 82 | Orderer: 83 | <<: *OrdererDefaults 84 | Organizations: 85 | - *OrdererOrg 86 | Consortiums: 87 | SampleConsortium: 88 | Organizations: 89 | - *Org1 90 | - *Org2 91 | - *Org3 92 | - *Org4 93 | FourOrgsChannel: 94 | Consortium: SampleConsortium 95 | Application: 96 | <<: *ApplicationDefaults 97 | Organizations: 98 | - *Org1 99 | - *Org2 100 | - *Org3 101 | - *Org4 102 | 103 | -------------------------------------------------------------------------------- /config/crypto-config.yaml: -------------------------------------------------------------------------------- 1 | OrdererOrgs: 2 | - Name: Orderer 3 | Domain: example.com 4 | Specs: 5 | - Hostname: orderer 6 | PeerOrgs: 7 | - Name: Org1 8 | Domain: org1.example.com 9 | Template: 10 | Count: 2 11 | Users: 12 | Count: 1 13 | - Name: Org2 14 | Domain: org2.example.com 15 | Template: 16 | Count: 2 17 | Users: 18 | Count: 1 19 | - Name: Org3 20 | Domain: org3.example.com 21 | Template: 22 | Count: 2 23 | Users: 24 | Count: 1 25 | - Name: Org4 26 | Domain: org4.example.com 27 | Template: 28 | Count: 2 29 | Users: 30 | Count: 1 31 | -------------------------------------------------------------------------------- /config/explorer/app/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "network-configs": { 3 | "network-1": { 4 | "version": "1.0", 5 | "clients": { 6 | "client-1": { 7 | "tlsEnable": false, 8 | "organization": "Org1MSP", 9 | "channel": "channel1", 10 | "credentialStore": { 11 | "path": "./tmp/credentialStore_Org1/credential", 12 | "cryptoStore": { 13 | "path": "./tmp/credentialStore_Org1/crypto" 14 | } 15 | } 16 | } 17 | }, 18 | "channels": { 19 | "channel1": { 20 | "peers": { 21 | "blockchain-org1peer1": {}, 22 | "blockchain-org2peer1": {}, 23 | "blockchain-org3peer1": {}, 24 | "blockchain-org4peer1": {}, 25 | "blockchain-org1peer2": {}, 26 | "blockchain-org2peer2": {}, 27 | "blockchain-org3peer2": {}, 28 | "blockchain-org4peer2": {} 29 | }, 30 | "orderers": { 31 | "blockchain-orderer" : {} 32 | }, 33 | "connection": { 34 | "timeout": { 35 | "peer": { 36 | "endorser": "6000", 37 | "eventHub": "6000", 38 | "eventReg": "6000" 39 | } 40 | } 41 | } 42 | } 43 | }, 44 | "organizations": { 45 | "Org1MSP": { 46 | "mspid": "Org1MSP", 47 | "fullpath": false, 48 | "adminPrivateKey": { 49 | "path": 50 | "/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore" 51 | }, 52 | "signedCert": { 53 | "path": 54 | "/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts" 55 | } 56 | }, 57 | "Org2MSP": { 58 | "mspid": "Org2MSP", 59 | "fullpath": false, 60 | "adminPrivateKey": { 61 | "path": 62 | "/fabric/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/keystore" 63 | }, 64 | "signedCert": { 65 | "path": 66 | "/fabric/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/signcerts" 67 | } 68 | }, 69 | "Org3MSP": { 70 | "mspid": "Org3MSP", 71 | "fullpath": false, 72 | "adminPrivateKey": { 73 | "path": 74 | "/fabric/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/keystore" 75 | }, 76 | "signedCert": { 77 | "path": 78 | "/fabric/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/signcerts" 79 | } 80 | }, 81 | "Org4MSP": { 82 | "mspid": "Org4MSP", 83 | "fullpath": false, 84 | "adminPrivateKey": { 85 | "path": 86 | "/fabric/crypto-config/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp/keystore" 87 | }, 88 | "signedCert": { 89 | "path": 90 | "/fabric/crypto-config/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp/signcerts" 91 | } 92 | }, 93 | "OrdererMSP": { 94 | "mspid": "OrdererMSP", 95 | "adminPrivateKey": { 96 | "path": 97 | "/fabric/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore" 98 | } 99 | } 100 | }, 101 | "peers": { 102 | "blockchain-org1peer1": { 103 | "tlsCACerts": { 104 | "path": 105 | "/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt" 106 | }, 107 | "url": "grpc://blockchain-org1peer1:30110", 108 | "eventUrl": "grpc://blockchain-org1peer1:30111", 109 | "grpcOptions": { 110 | "ssl-target-name-override": "peer0.org1.example.com" 111 | } 112 | }, 113 | "blockchain-org2peer1": { 114 | "tlsCACerts": { 115 | "path": 116 | "/fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt" 117 | }, 118 | "url": "grpc://blockchain-org2peer1:30110", 119 | "eventUrl": "grpc://blockchain-org2peer1:30111", 120 | "grpcOptions": { 121 | "ssl-target-name-override": "peer0.org2.example.com" 122 | } 123 | }, 124 | "blockchain-org3peer1": { 125 | "tlsCACerts": { 126 | "path": 127 | "/fabric/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt" 128 | }, 129 | "url": "grpc://blockchain-org3peer1:30110", 130 | "eventUrl": "grpc://blockchain-org3peer1:30111", 131 | "grpcOptions": { 132 | "ssl-target-name-override": "peer0.org3.example.com" 133 | } 134 | }, 135 | "blockchain-org4peer1": { 136 | "tlsCACerts": { 137 | "path": 138 | "/fabric/crypto-config/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/ca.crt" 139 | }, 140 | "url": "grpc://blockchain-org4peer1:30110", 141 | "eventUrl": "grpc://blockchain-org4peer1:30111", 142 | "grpcOptions": { 143 | "ssl-target-name-override": "peer0.org4.example.com" 144 | } 145 | }, 146 | "blockchain-org1peer2": { 147 | "tlsCACerts": { 148 | "path": 149 | "/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt" 150 | }, 151 | "url": "grpc://blockchain-org1peer2:30110", 152 | "eventUrl": "grpc://blockchain-org1peer2:30111", 153 | "grpcOptions": { 154 | "ssl-target-name-override": "peer1.org1.example.com" 155 | } 156 | }, 157 | "blockchain-org2peer2": { 158 | "tlsCACerts": { 159 | "path": 160 | "/fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/ca.crt" 161 | }, 162 | "url": "grpc://blockchain-org2peer2:30110", 163 | "eventUrl": "grpc://blockchain-org2peer2:30111", 164 | "grpcOptions": { 165 | "ssl-target-name-override": "peer1.org2.example.com" 166 | } 167 | }, 168 | "blockchain-org3peer2": { 169 | "tlsCACerts": { 170 | "path": 171 | "/fabric/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/tls/ca.crt" 172 | }, 173 | "url": "grpc://blockchain-org3peer2:30110", 174 | "eventUrl": "grpc://blockchain-org3peer2:30111", 175 | "grpcOptions": { 176 | "ssl-target-name-override": "peer1.org3.example.com" 177 | } 178 | }, 179 | "blockchain-org4peer2": { 180 | "tlsCACerts": { 181 | "path": 182 | "/fabric/crypto-config/peerOrganizations/org4.example.com/peers/peer1.org4.example.com/tls/ca.crt" 183 | }, 184 | "url": "grpc://blockchain-org4peer2:30110", 185 | "eventUrl": "grpc://blockchain-org4peer2:30111", 186 | "grpcOptions": { 187 | "ssl-target-name-override": "peer1.org4.example.com" 188 | } 189 | } 190 | }, 191 | "orderers": { 192 | "blockchain-orderer": { 193 | "url": "grpc://blockchain-orderer:31010" 194 | } 195 | } 196 | } 197 | }, 198 | "configtxgenToolPath": "/fabric-path/workspace/fabric-samples/bin", 199 | "license": "Apache-2.0" 200 | } 201 | -------------------------------------------------------------------------------- /config/explorer/app/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p /opt/explorer/app/platform/fabric/ 3 | mkdir -p /tmp/ 4 | 5 | mv /opt/explorer/app/platform/fabric/config.json /opt/explorer/app/platform/fabric/config.json.vanilla 6 | cp /fabric/config/explorer/app/config.json /opt/explorer/app/platform/fabric/config.json 7 | 8 | cd /opt/explorer 9 | node $EXPLORER_APP_PATH/main.js && tail -f /dev/null 10 | -------------------------------------------------------------------------------- /images/slide1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitnomore/hyperledger-fabric-kubernetes/f569bd39728a3e210f839104dff97264c9fa29f9/images/slide1.jpg -------------------------------------------------------------------------------- /images/slide2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitnomore/hyperledger-fabric-kubernetes/f569bd39728a3e210f839104dff97264c9fa29f9/images/slide2.jpg -------------------------------------------------------------------------------- /images/slide3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitnomore/hyperledger-fabric-kubernetes/f569bd39728a3e210f839104dff97264c9fa29f9/images/slide3.jpg -------------------------------------------------------------------------------- /images/slide4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitnomore/hyperledger-fabric-kubernetes/f569bd39728a3e210f839104dff97264c9fa29f9/images/slide4.jpg -------------------------------------------------------------------------------- /images/slide5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitnomore/hyperledger-fabric-kubernetes/f569bd39728a3e210f839104dff97264c9fa29f9/images/slide5.jpg -------------------------------------------------------------------------------- /images/slide6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitnomore/hyperledger-fabric-kubernetes/f569bd39728a3e210f839104dff97264c9fa29f9/images/slide6.jpg -------------------------------------------------------------------------------- /images/slide7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feitnomore/hyperledger-fabric-kubernetes/f569bd39728a3e210f839104dff97264c9fa29f9/images/slide7.jpg -------------------------------------------------------------------------------- /kubernetes/blockchain-ca_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-ca 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: ca 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | 17 | containers: 18 | - name: ca 19 | image: hyperledger/fabric-ca:amd64-1.3.0 20 | command: ["sh", "-c", "fabric-ca-server start -b admin:adminpw -d"] 21 | env: 22 | - name: TZ 23 | value: "America/Sao_Paulo" 24 | - name: FABRIC_CA_SERVER_CA_NAME 25 | value: "CA1" 26 | - name: FABRIC_CA_SERVER_CA_CERTFILE 27 | value: /fabric/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem 28 | - name: FABRIC_CA_SERVER_CA_KEYFILE 29 | value: /fabric/crypto-config/peerOrganizations/org1.example.com/ca/key.pem 30 | - name: FABRIC_CA_SERVER_DEBUG 31 | value: "true" 32 | - name: FABRIC_CA_SERVER_TLS_ENABLED 33 | value: "false" 34 | - name: FABRIC_CA_SERVER_TLS_CERTFILE 35 | value: /certs/ca0a-cert.pem 36 | - name: FABRIC_CA_SERVER_TLS_KEYFILE 37 | value: /certs/ca0a-key.pem 38 | - name: GODEBUG 39 | value: "netdns=go" 40 | volumeMounts: 41 | - mountPath: /fabric 42 | name: fabricfiles 43 | -------------------------------------------------------------------------------- /kubernetes/blockchain-ca_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-ca 5 | labels: 6 | run: blockchain-ca 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: ca 11 | ports: 12 | - protocol: TCP 13 | port: 30054 14 | targetPort: 7054 15 | name: grpc 16 | - protocol: TCP 17 | port: 7054 18 | name: grpc1 19 | -------------------------------------------------------------------------------- /kubernetes/blockchain-explorer-app_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-explorer-app 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: explorer 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | 17 | containers: 18 | - name: explorer 19 | image: hyperledger/explorer:latest 20 | command: ["sh" , "-c" , "/fabric/config/explorer/app/run.sh"] 21 | env: 22 | - name: TZ 23 | value: "America/Sao_Paulo" 24 | - name: DATABASE_HOST 25 | value: blockchain-explorer-db 26 | - name: DATABASE_USERNAME 27 | value: hppoc 28 | - name: DATABASE_PASSWORD 29 | value: password 30 | volumeMounts: 31 | - mountPath: /fabric 32 | name: fabricfiles 33 | -------------------------------------------------------------------------------- /kubernetes/blockchain-explorer-db_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-explorer-db 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: explorer-db 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | 17 | containers: 18 | - name: postgres 19 | image: postgres:10.4-alpine 20 | env: 21 | - name: TZ 22 | value: "America/Sao_Paulo" 23 | - name: DATABASE_DATABASE 24 | value: fabricexplorer 25 | - name: DATABASE_USERNAME 26 | value: hppoc 27 | - name: DATABASE_PASSWORD 28 | value: password 29 | volumeMounts: 30 | - mountPath: /fabric 31 | name: fabricfiles 32 | -------------------------------------------------------------------------------- /kubernetes/blockchain-explorer-db_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-explorer-db 5 | labels: 6 | run: explorer-db 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: explorer-db 11 | ports: 12 | - protocol: TCP 13 | port: 5432 14 | targetPort: 5432 15 | name: pgsql 16 | -------------------------------------------------------------------------------- /kubernetes/blockchain-orderer_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-orderer 5 | spec: 6 | replicas: 3 7 | selector: 8 | matchLabels: 9 | name: orderer 10 | template: 11 | metadata: 12 | labels: 13 | name: orderer 14 | spec: 15 | volumes: 16 | - name: fabricfiles 17 | persistentVolumeClaim: 18 | claimName: fabric-pvc 19 | 20 | containers: 21 | - name: orderer 22 | image: hyperledger/fabric-orderer:amd64-1.3.0 23 | command: ["sh", "-c", "orderer"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: ORDERER_CFG_PATH 28 | value: /fabric/ 29 | - name: ORDERER_GENERAL_LEDGERTYPE 30 | value: file 31 | - name: ORDERER_FILELEDGER_LOCATION 32 | value: /fabric/ledger/orderer 33 | - name: ORDERER_GENERAL_BATCHTIMEOUT 34 | value: 1s 35 | - name: ORDERER_GENERAL_BATCHSIZE_MAXMESSAGECOUNT 36 | value: "10" 37 | - name: ORDERER_GENERAL_MAXWINDOWSIZE 38 | value: "1000" 39 | - name: CONFIGTX_GENERAL_ORDERERTYPE 40 | value: kafka 41 | - name: CONFIGTX_ORDERER_KAFKA_BROKERS 42 | value: "kafka1.local.parisi.biz:9092,kafka2.local.parisi.biz:9092,kafka3.local.parisi.biz:9092,kafka4.local.parisi.biz:9092" 43 | - name: ORDERER_KAFKA_RETRY_SHORTINTERVAL 44 | value: 1s 45 | - name: ORDERER_KAFKA_RETRY_SHORTTOTAL 46 | value: 30s 47 | - name: ORDERER_KAFKA_VERBOSE 48 | value: "true" 49 | - name: CONFIGTX_ORDERER_ADDRESSES 50 | value: "blockchain-orderer:31010" 51 | - name: ORDERER_GENERAL_LISTENADDRESS 52 | value: 0.0.0.0 53 | - name: ORDERER_GENERAL_LISTENPORT 54 | value: "31010" 55 | - name: ORDERER_GENERAL_LOGLEVEL 56 | value: debug 57 | - name: ORDERER_GENERAL_LOCALMSPDIR 58 | value: /fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp 59 | - name: ORDERER_GENERAL_LOCALMSPID 60 | value: OrdererMSP 61 | - name: ORDERER_GENERAL_GENESISMETHOD 62 | value: file 63 | - name: ORDERER_GENERAL_GENESISFILE 64 | value: /fabric/genesis.block 65 | - name: ORDERER_GENERAL_GENESISPROFILE 66 | value: initial 67 | - name: ORDERER_GENERAL_TLS_ENABLED 68 | value: "false" 69 | - name: GODEBUG 70 | value: "netdns=go" 71 | - name: ORDERER_GENERAL_LEDGERTYPE 72 | value: "ram" 73 | volumeMounts: 74 | - mountPath: /fabric 75 | name: fabricfiles -------------------------------------------------------------------------------- /kubernetes/blockchain-orderer_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-orderer 5 | labels: 6 | run: blockchain-orderer 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: orderer 11 | ports: 12 | - protocol: TCP 13 | port: 31010 14 | name: grpc 15 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org1peer1_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-org1peer1 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: org1peer1 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | - name: dockersocket 17 | hostPath: 18 | path: /var/run/docker.sock 19 | 20 | containers: 21 | - name: peer 22 | image: hyperledger/fabric-peer:amd64-1.3.0 23 | command: ["sh", "-c", "peer node start"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: CORE_PEER_ADDRESSAUTODETECT 28 | value: "true" 29 | - name: CORE_PEER_NETWORKID 30 | value: nid1 31 | - name: CORE_PEER_ID 32 | value: blockchain-org1peer1 33 | - name: CORE_PEER_ADDRESS 34 | value: blockchain-org1peer1:30110 35 | - name: CORE_PEER_LISTENADDRESS 36 | value: 0.0.0.0:30110 37 | - name: CORE_PEER_EVENTS_ADDRESS 38 | value: 0.0.0.0:30111 39 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 40 | value: blockchain-org1peer1:30110 41 | - name: CORE_PEER_GOSSIP_ENDPOINT 42 | value: blockchain-org1peer1:30110 43 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 44 | value: blockchain-org1peer1:30110 45 | - name: CORE_PEER_GOSSIP_ORGLEADER 46 | value: "false" 47 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 48 | value: "true" 49 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 50 | value: "true" 51 | - name: CORE_PEER_COMMITTER_ENABLED 52 | value: "true" 53 | - name: CORE_PEER_PROFILE_ENABLED 54 | value: "true" 55 | - name: CORE_VM_ENDPOINT 56 | value: unix:///host/var/run/docker.sock 57 | - name: CORE_PEER_LOCALMSPID 58 | value: Org1MSP 59 | - name: CORE_PEER_MSPCONFIGPATH 60 | value: /fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/ 61 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 62 | value: "pbft" 63 | - name: CORE_PBFT_GENERAL_MODE 64 | value: "classic" 65 | - name: CORE_PBFT_GENERAL_N 66 | value: "4" 67 | - name: CORE_LOGGING_LEVEL 68 | value: debug 69 | - name: CORE_LOGGING_PEER 70 | value: debug 71 | - name: CORE_LOGGING_CAUTHDSL 72 | value: debug 73 | - name: CORE_LOGGING_GOSSIP 74 | value: debug 75 | - name: CORE_LOGGING_LEDGER 76 | value: debug 77 | - name: CORE_LOGGING_MSP 78 | value: info 79 | - name: CORE_LOGGING_POLICIES 80 | value: debug 81 | - name: CORE_LOGGING_GRPC 82 | value: debug 83 | - name: CORE_PEER_TLS_ENABLED 84 | value: "false" 85 | - name: CORE_LEDGER_STATE_STATEDATABASE 86 | value: "CouchDB" 87 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 88 | value: "localhost:5984" 89 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 90 | value: "hyperledgeruser" 91 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 92 | value: "hyperledgerpass" 93 | - name: FABRIC_CFG_PATH 94 | value: /etc/hyperledger/fabric/ 95 | - name: ORDERER_URL 96 | value: blockchain-orderer:31010 97 | - name: GODEBUG 98 | value: "netdns=go" 99 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 100 | value: "true" 101 | volumeMounts: 102 | - mountPath: /fabric 103 | name: fabricfiles 104 | - mountPath: /host/var/run/docker.sock 105 | name: dockersocket 106 | - name: couchdb 107 | image: hyperledger/fabric-couchdb:amd64-0.4.14 108 | env: 109 | - name: TZ 110 | value: "America/Sao_Paulo" 111 | - name: COUCHDB_USER 112 | value: "hyperledgeruser" 113 | - name: COUCHDB_PASSWORD 114 | value: "hyperledgerpass" 115 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org1peer1_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-org1peer1 5 | labels: 6 | run: blockchain-org1peer1 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: org1peer1 11 | ports: 12 | - protocol: TCP 13 | port: 30110 14 | name: grpc 15 | - protocol: TCP 16 | port: 30111 17 | name: events 18 | - protocol: TCP 19 | port: 5984 20 | name: couchdb 21 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org1peer2_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-org1peer2 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: org1peer2 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | - name: dockersocket 17 | hostPath: 18 | path: /var/run/docker.sock 19 | 20 | containers: 21 | - name: peer 22 | image: hyperledger/fabric-peer:amd64-1.3.0 23 | command: ["sh", "-c", "peer node start"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: CORE_PEER_ADDRESSAUTODETECT 28 | value: "true" 29 | - name: CORE_PEER_NETWORKID 30 | value: nid1 31 | - name: CORE_PEER_ID 32 | value: blockchain-org1peer2 33 | - name: CORE_PEER_ADDRESS 34 | value: blockchain-org1peer2:30110 35 | - name: CORE_PEER_LISTENADDRESS 36 | value: 0.0.0.0:30110 37 | - name: CORE_PEER_EVENTS_ADDRESS 38 | value: 0.0.0.0:30111 39 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 40 | value: blockchain-org1peer2:30110 41 | - name: CORE_PEER_GOSSIP_ENDPOINT 42 | value: blockchain-org1peer2:30110 43 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 44 | value: blockchain-org1peer2:30110 45 | - name: CORE_PEER_GOSSIP_ORGLEADER 46 | value: "false" 47 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 48 | value: "true" 49 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 50 | value: "true" 51 | - name: CORE_PEER_COMMITTER_ENABLED 52 | value: "true" 53 | - name: CORE_PEER_PROFILE_ENABLED 54 | value: "true" 55 | - name: CORE_VM_ENDPOINT 56 | value: unix:///host/var/run/docker.sock 57 | - name: CORE_PEER_LOCALMSPID 58 | value: Org1MSP 59 | - name: CORE_PEER_MSPCONFIGPATH 60 | value: /fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp/ 61 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 62 | value: "pbft" 63 | - name: CORE_PBFT_GENERAL_MODE 64 | value: "classic" 65 | - name: CORE_PBFT_GENERAL_N 66 | value: "4" 67 | - name: CORE_LOGGING_LEVEL 68 | value: debug 69 | - name: CORE_LOGGING_PEER 70 | value: debug 71 | - name: CORE_LOGGING_CAUTHDSL 72 | value: debug 73 | - name: CORE_LOGGING_GOSSIP 74 | value: debug 75 | - name: CORE_LOGGING_LEDGER 76 | value: debug 77 | - name: CORE_LOGGING_MSP 78 | value: info 79 | - name: CORE_LOGGING_POLICIES 80 | value: debug 81 | - name: CORE_LOGGING_GRPC 82 | value: debug 83 | - name: CORE_PEER_TLS_ENABLED 84 | value: "false" 85 | - name: CORE_LEDGER_STATE_STATEDATABASE 86 | value: "CouchDB" 87 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 88 | value: "localhost:5984" 89 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 90 | value: "hyperledgeruser" 91 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 92 | value: "hyperledgerpass" 93 | - name: FABRIC_CFG_PATH 94 | value: /etc/hyperledger/fabric/ 95 | - name: ORDERER_URL 96 | value: blockchain-orderer:31010 97 | - name: GODEBUG 98 | value: "netdns=go" 99 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 100 | value: "true" 101 | volumeMounts: 102 | - mountPath: /fabric 103 | name: fabricfiles 104 | - mountPath: /host/var/run/docker.sock 105 | name: dockersocket 106 | - name: couchdb 107 | image: hyperledger/fabric-couchdb:amd64-0.4.14 108 | env: 109 | - name: TZ 110 | value: "America/Sao_Paulo" 111 | - name: COUCHDB_USER 112 | value: "hyperledgeruser" 113 | - name: COUCHDB_PASSWORD 114 | value: "hyperledgerpass" 115 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org1peer2_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-org1peer2 5 | labels: 6 | run: blockchain-org1peer2 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: org1peer2 11 | ports: 12 | - protocol: TCP 13 | port: 30110 14 | name: grpc 15 | - protocol: TCP 16 | port: 30111 17 | name: events 18 | - protocol: TCP 19 | port: 5984 20 | name: couchdb 21 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org2peer1_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-org2peer1 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: org2peer1 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | - name: dockersocket 17 | hostPath: 18 | path: /var/run/docker.sock 19 | 20 | containers: 21 | - name: peer 22 | image: hyperledger/fabric-peer:amd64-1.3.0 23 | command: ["sh", "-c", "peer node start"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: CORE_PEER_ADDRESSAUTODETECT 28 | value: "true" 29 | - name: CORE_PEER_ID 30 | value: blockchain-org2peer1 31 | - name: CORE_PEER_NETWORKID 32 | value: nid1 33 | - name: CORE_PEER_ADDRESS 34 | value: blockchain-org2peer1:30110 35 | - name: CORE_PEER_LISTENADDRESS 36 | value: 0.0.0.0:30110 37 | - name: CORE_PEER_EVENTS_ADDRESS 38 | value: 0.0.0.0:30111 39 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 40 | value: blockchain-org2peer1:30110 41 | - name: CORE_PEER_GOSSIP_ENDPOINT 42 | value: blockchain-org2peer1:30110 43 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 44 | value: blockchain-org2peer1:30110 45 | - name: CORE_PEER_GOSSIP_ORGLEADER 46 | value: "false" 47 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 48 | value: "true" 49 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 50 | value: "true" 51 | - name: CORE_PEER_COMMITTER_ENABLED 52 | value: "false" 53 | - name: CORE_PEER_PROFILE_ENABLED 54 | value: "true" 55 | - name: CORE_VM_ENDPOINT 56 | value: unix:///host/var/run/docker.sock 57 | - name: CORE_PEER_LOCALMSPID 58 | value: Org2MSP 59 | - name: CORE_PEER_MSPCONFIGPATH 60 | value: /fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/ 61 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 62 | value: "pbft" 63 | - name: CORE_PBFT_GENERAL_MODE 64 | value: "classic" 65 | - name: CORE_PBFT_GENERAL_N 66 | value: "4" 67 | - name: CORE_LOGGING_LEVEL 68 | value: debug 69 | - name: CORE_LOGGING_PEER 70 | value: debug 71 | - name: CORE_LOGGING_CAUTHDSL 72 | value: debug 73 | - name: CORE_LOGGING_GOSSIP 74 | value: debug 75 | - name: CORE_LOGGING_LEDGER 76 | value: debug 77 | - name: CORE_LOGGING_MSP 78 | value: debug 79 | - name: CORE_LOGGING_POLICIES 80 | value: debug 81 | - name: CORE_LOGGING_GRPC 82 | value: debug 83 | - name: CORE_PEER_TLS_ENABLED 84 | value: "false" 85 | - name: CORE_LEDGER_STATE_STATEDATABASE 86 | value: "CouchDB" 87 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 88 | value: "localhost:5984" 89 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 90 | value: "hyperledgeruser" 91 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 92 | value: "hyperledgerpass" 93 | - name: FABRIC_CFG_PATH 94 | value: /etc/hyperledger/fabric/ 95 | - name: ORDERER_URL 96 | value: blockchain-orderer:31010 97 | - name: GODEBUG 98 | value: "netdns=go" 99 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 100 | value: "true" 101 | volumeMounts: 102 | - mountPath: /fabric 103 | name: fabricfiles 104 | - mountPath: /host/var/run/docker.sock 105 | name: dockersocket 106 | - name: couchdb 107 | image: hyperledger/fabric-couchdb:amd64-0.4.14 108 | env: 109 | - name: TZ 110 | value: "America/Sao_Paulo" 111 | - name: COUCHDB_USER 112 | value: "hyperledgeruser" 113 | - name: COUCHDB_PASSWORD 114 | value: "hyperledgerpass" 115 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org2peer1_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-org2peer1 5 | labels: 6 | run: blockchain-org2peer1 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: org2peer1 11 | ports: 12 | - protocol: TCP 13 | port: 30110 14 | name: grpc 15 | - protocol: TCP 16 | port: 30111 17 | name: events 18 | - protocol: TCP 19 | port: 5984 20 | name: couchdb 21 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org2peer2_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-org2peer2 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: org2peer2 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | - name: dockersocket 17 | hostPath: 18 | path: /var/run/docker.sock 19 | 20 | containers: 21 | - name: peer 22 | image: hyperledger/fabric-peer:amd64-1.3.0 23 | command: ["sh", "-c", "peer node start"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: CORE_PEER_ADDRESSAUTODETECT 28 | value: "true" 29 | - name: CORE_PEER_ID 30 | value: blockchain-org2peer2 31 | - name: CORE_PEER_NETWORKID 32 | value: nid1 33 | - name: CORE_PEER_ADDRESS 34 | value: blockchain-org2peer2:30110 35 | - name: CORE_PEER_LISTENADDRESS 36 | value: 0.0.0.0:30110 37 | - name: CORE_PEER_EVENTS_ADDRESS 38 | value: 0.0.0.0:30111 39 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 40 | value: blockchain-org2peer2:30110 41 | - name: CORE_PEER_GOSSIP_ENDPOINT 42 | value: blockchain-org2peer2:30110 43 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 44 | value: blockchain-org2peer2:30110 45 | - name: CORE_PEER_GOSSIP_ORGLEADER 46 | value: "false" 47 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 48 | value: "true" 49 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 50 | value: "true" 51 | - name: CORE_PEER_COMMITTER_ENABLED 52 | value: "false" 53 | - name: CORE_PEER_PROFILE_ENABLED 54 | value: "true" 55 | - name: CORE_VM_ENDPOINT 56 | value: unix:///host/var/run/docker.sock 57 | - name: CORE_PEER_LOCALMSPID 58 | value: Org2MSP 59 | - name: CORE_PEER_MSPCONFIGPATH 60 | value: /fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/ 61 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 62 | value: "pbft" 63 | - name: CORE_PBFT_GENERAL_MODE 64 | value: "classic" 65 | - name: CORE_PBFT_GENERAL_N 66 | value: "4" 67 | - name: CORE_LOGGING_LEVEL 68 | value: debug 69 | - name: CORE_LOGGING_PEER 70 | value: debug 71 | - name: CORE_LOGGING_CAUTHDSL 72 | value: debug 73 | - name: CORE_LOGGING_GOSSIP 74 | value: debug 75 | - name: CORE_LOGGING_LEDGER 76 | value: debug 77 | - name: CORE_LOGGING_MSP 78 | value: debug 79 | - name: CORE_LOGGING_POLICIES 80 | value: debug 81 | - name: CORE_LOGGING_GRPC 82 | value: debug 83 | - name: CORE_PEER_TLS_ENABLED 84 | value: "false" 85 | - name: CORE_LEDGER_STATE_STATEDATABASE 86 | value: "CouchDB" 87 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 88 | value: "localhost:5984" 89 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 90 | value: "hyperledgeruser" 91 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 92 | value: "hyperledgerpass" 93 | - name: FABRIC_CFG_PATH 94 | value: /etc/hyperledger/fabric/ 95 | - name: ORDERER_URL 96 | value: blockchain-orderer:31010 97 | - name: GODEBUG 98 | value: "netdns=go" 99 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 100 | value: "true" 101 | volumeMounts: 102 | - mountPath: /fabric 103 | name: fabricfiles 104 | - mountPath: /host/var/run/docker.sock 105 | name: dockersocket 106 | - name: couchdb 107 | image: hyperledger/fabric-couchdb:amd64-0.4.14 108 | env: 109 | - name: TZ 110 | value: "America/Sao_Paulo" 111 | - name: COUCHDB_USER 112 | value: "hyperledgeruser" 113 | - name: COUCHDB_PASSWORD 114 | value: "hyperledgerpass" 115 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org2peer2_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-org2peer2 5 | labels: 6 | run: blockchain-org2peer2 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: org2peer2 11 | ports: 12 | - protocol: TCP 13 | port: 30110 14 | name: grpc 15 | - protocol: TCP 16 | port: 30111 17 | name: events 18 | - protocol: TCP 19 | port: 5984 20 | name: couchdb 21 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org3peer1_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-org3peer1 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: org3peer1 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | - name: dockersocket 17 | hostPath: 18 | path: /var/run/docker.sock 19 | 20 | containers: 21 | - name: peer 22 | image: hyperledger/fabric-peer:amd64-1.3.0 23 | command: ["sh", "-c", "peer node start"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: CORE_PEER_ADDRESSAUTODETECT 28 | value: "true" 29 | - name: CORE_PEER_ID 30 | value: blockchain-org3peer1 31 | - name: CORE_PEER_NETWORKID 32 | value: nid1 33 | - name: CORE_PEER_ADDRESS 34 | value: blockchain-org3peer1:30110 35 | - name: CORE_PEER_LISTENADDRESS 36 | value: 0.0.0.0:30110 37 | - name: CORE_PEER_EVENTS_ADDRESS 38 | value: 0.0.0.0:30111 39 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 40 | value: blockchain-org3peer1:30110 41 | - name: CORE_PEER_GOSSIP_ENDPOINT 42 | value: blockchain-org3peer1:30110 43 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 44 | value: blockchain-org3peer1:30110 45 | - name: CORE_PEER_GOSSIP_ORGLEADER 46 | value: "false" 47 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 48 | value: "true" 49 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 50 | value: "true" 51 | - name: CORE_PEER_COMMITTER_ENABLED 52 | value: "false" 53 | - name: CORE_PEER_PROFILE_ENABLED 54 | value: "true" 55 | - name: CORE_VM_ENDPOINT 56 | value: unix:///host/var/run/docker.sock 57 | - name: CORE_PEER_LOCALMSPID 58 | value: Org3MSP 59 | - name: CORE_PEER_MSPCONFIGPATH 60 | value: /fabric/crypto-config/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/ 61 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 62 | value: "pbft" 63 | - name: CORE_PBFT_GENERAL_MODE 64 | value: "classic" 65 | - name: CORE_PBFT_GENERAL_N 66 | value: "4" 67 | - name: CORE_LOGGING_LEVEL 68 | value: debug 69 | - name: CORE_LOGGING_PEER 70 | value: debug 71 | - name: CORE_LOGGING_CAUTHDSL 72 | value: debug 73 | - name: CORE_LOGGING_GOSSIP 74 | value: debug 75 | - name: CORE_LOGGING_LEDGER 76 | value: debug 77 | - name: CORE_LOGGING_MSP 78 | value: debug 79 | - name: CORE_LOGGING_POLICIES 80 | value: debug 81 | - name: CORE_LOGGING_GRPC 82 | value: debug 83 | - name: CORE_PEER_TLS_ENABLED 84 | value: "false" 85 | - name: CORE_LEDGER_STATE_STATEDATABASE 86 | value: "CouchDB" 87 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 88 | value: "localhost:5984" 89 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 90 | value: "hyperledgeruser" 91 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 92 | value: "hyperledgerpass" 93 | - name: FABRIC_CFG_PATH 94 | value: /etc/hyperledger/fabric/ 95 | - name: ORDERER_URL 96 | value: blockchain-orderer:31010 97 | - name: GODEBUG 98 | value: "netdns=go" 99 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 100 | value: "true" 101 | volumeMounts: 102 | - mountPath: /fabric 103 | name: fabricfiles 104 | - mountPath: /host/var/run/docker.sock 105 | name: dockersocket 106 | - name: couchdb 107 | image: hyperledger/fabric-couchdb:amd64-0.4.14 108 | env: 109 | - name: TZ 110 | value: "America/Sao_Paulo" 111 | - name: COUCHDB_USER 112 | value: "hyperledgeruser" 113 | - name: COUCHDB_PASSWORD 114 | value: "hyperledgerpass" 115 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org3peer1_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-org3peer1 5 | labels: 6 | run: blockchain-org3peer1 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: org3peer1 11 | ports: 12 | - protocol: TCP 13 | port: 30110 14 | name: grpc 15 | - protocol: TCP 16 | port: 30111 17 | name: events 18 | - protocol: TCP 19 | port: 5984 20 | name: couchdb 21 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org3peer2_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-org3peer2 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: org3peer2 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | - name: dockersocket 17 | hostPath: 18 | path: /var/run/docker.sock 19 | 20 | containers: 21 | - name: peer 22 | image: hyperledger/fabric-peer:amd64-1.3.0 23 | command: ["sh", "-c", "peer node start"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: CORE_PEER_ADDRESSAUTODETECT 28 | value: "true" 29 | - name: CORE_PEER_ID 30 | value: blockchain-org3peer2 31 | - name: CORE_PEER_NETWORKID 32 | value: nid1 33 | - name: CORE_PEER_ADDRESS 34 | value: blockchain-org3peer2:30110 35 | - name: CORE_PEER_LISTENADDRESS 36 | value: 0.0.0.0:30110 37 | - name: CORE_PEER_EVENTS_ADDRESS 38 | value: 0.0.0.0:30111 39 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 40 | value: blockchain-org3peer2:30110 41 | - name: CORE_PEER_GOSSIP_ENDPOINT 42 | value: blockchain-org3peer2:30110 43 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 44 | value: blockchain-org3peer2:30110 45 | - name: CORE_PEER_GOSSIP_ORGLEADER 46 | value: "false" 47 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 48 | value: "true" 49 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 50 | value: "true" 51 | - name: CORE_PEER_COMMITTER_ENABLED 52 | value: "false" 53 | - name: CORE_PEER_PROFILE_ENABLED 54 | value: "true" 55 | - name: CORE_VM_ENDPOINT 56 | value: unix:///host/var/run/docker.sock 57 | - name: CORE_PEER_LOCALMSPID 58 | value: Org3MSP 59 | - name: CORE_PEER_MSPCONFIGPATH 60 | value: /fabric/crypto-config/peerOrganizations/org3.example.com/peers/peer1.org3.example.com/msp/ 61 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 62 | value: "pbft" 63 | - name: CORE_PBFT_GENERAL_MODE 64 | value: "classic" 65 | - name: CORE_PBFT_GENERAL_N 66 | value: "4" 67 | - name: CORE_LOGGING_LEVEL 68 | value: debug 69 | - name: CORE_LOGGING_PEER 70 | value: debug 71 | - name: CORE_LOGGING_CAUTHDSL 72 | value: debug 73 | - name: CORE_LOGGING_GOSSIP 74 | value: debug 75 | - name: CORE_LOGGING_LEDGER 76 | value: debug 77 | - name: CORE_LOGGING_MSP 78 | value: debug 79 | - name: CORE_LOGGING_POLICIES 80 | value: debug 81 | - name: CORE_LOGGING_GRPC 82 | value: debug 83 | - name: CORE_PEER_TLS_ENABLED 84 | value: "false" 85 | - name: CORE_LEDGER_STATE_STATEDATABASE 86 | value: "CouchDB" 87 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 88 | value: "localhost:5984" 89 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 90 | value: "hyperledgeruser" 91 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 92 | value: "hyperledgerpass" 93 | - name: FABRIC_CFG_PATH 94 | value: /etc/hyperledger/fabric/ 95 | - name: ORDERER_URL 96 | value: blockchain-orderer:31010 97 | - name: GODEBUG 98 | value: "netdns=go" 99 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 100 | value: "true" 101 | volumeMounts: 102 | - mountPath: /fabric 103 | name: fabricfiles 104 | - mountPath: /host/var/run/docker.sock 105 | name: dockersocket 106 | - name: couchdb 107 | image: hyperledger/fabric-couchdb:amd64-0.4.14 108 | env: 109 | - name: TZ 110 | value: "America/Sao_Paulo" 111 | - name: COUCHDB_USER 112 | value: "hyperledgeruser" 113 | - name: COUCHDB_PASSWORD 114 | value: "hyperledgerpass" 115 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org3peer2_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-org3peer2 5 | labels: 6 | run: blockchain-org3peer2 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: org3peer2 11 | ports: 12 | - protocol: TCP 13 | port: 30110 14 | name: grpc 15 | - protocol: TCP 16 | port: 30111 17 | name: events 18 | - protocol: TCP 19 | port: 5984 20 | name: couchdb 21 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org4peer1_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-org4peer1 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: org4peer1 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | - name: dockersocket 17 | hostPath: 18 | path: /var/run/docker.sock 19 | 20 | containers: 21 | - name: peer 22 | image: hyperledger/fabric-peer:amd64-1.3.0 23 | command: ["sh", "-c", "peer node start"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: CORE_PEER_ADDRESSAUTODETECT 28 | value: "true" 29 | - name: CORE_PEER_ID 30 | value: blockchain-org4peer1 31 | - name: CORE_PEER_NETWORKID 32 | value: nid1 33 | - name: CORE_PEER_ADDRESS 34 | value: blockchain-org4peer1:30110 35 | - name: CORE_PEER_LISTENADDRESS 36 | value: 0.0.0.0:30110 37 | - name: CORE_PEER_EVENTS_ADDRESS 38 | value: 0.0.0.0:30111 39 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 40 | value: blockchain-org4peer1:30110 41 | - name: CORE_PEER_GOSSIP_ENDPOINT 42 | value: blockchain-org4peer1:30110 43 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 44 | value: blockchain-org4peer1:30110 45 | - name: CORE_PEER_GOSSIP_ORGLEADER 46 | value: "false" 47 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 48 | value: "true" 49 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 50 | value: "false" 51 | - name: CORE_PEER_COMMITTER_ENABLED 52 | value: "true" 53 | - name: CORE_PEER_PROFILE_ENABLED 54 | value: "true" 55 | - name: CORE_VM_ENDPOINT 56 | value: unix:///host/var/run/docker.sock 57 | - name: CORE_PEER_LOCALMSPID 58 | value: Org4MSP 59 | - name: CORE_PEER_MSPCONFIGPATH 60 | value: /fabric/crypto-config/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp/ 61 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 62 | value: "pbft" 63 | - name: CORE_PBFT_GENERAL_MODE 64 | value: "classic" 65 | - name: CORE_PBFT_GENERAL_N 66 | value: "4" 67 | - name: CORE_LOGGING_LEVEL 68 | value: debug 69 | - name: CORE_LOGGING_PEER 70 | value: debug 71 | - name: CORE_LOGGING_CAUTHDSL 72 | value: debug 73 | - name: CORE_LOGGING_GOSSIP 74 | value: debug 75 | - name: CORE_LOGGING_LEDGER 76 | value: debug 77 | - name: CORE_LOGGING_MSP 78 | value: debug 79 | - name: CORE_LOGGING_POLICIES 80 | value: debug 81 | - name: CORE_LOGGING_GRPC 82 | value: debug 83 | - name: CORE_PEER_TLS_ENABLED 84 | value: "false" 85 | - name: CORE_LEDGER_STATE_STATEDATABASE 86 | value: "CouchDB" 87 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 88 | value: "localhost:5984" 89 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 90 | value: "hyperledgeruser" 91 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 92 | value: "hyperledgerpass" 93 | - name: FABRIC_CFG_PATH 94 | value: /etc/hyperledger/fabric/ 95 | - name: ORDERER_URL 96 | value: blockchain-orderer:31010 97 | - name: GODEBUG 98 | value: "netdns=go" 99 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 100 | value: "true" 101 | volumeMounts: 102 | - mountPath: /fabric 103 | name: fabricfiles 104 | - mountPath: /host/var/run/docker.sock 105 | name: dockersocket 106 | - name: couchdb 107 | image: hyperledger/fabric-couchdb:amd64-0.4.14 108 | env: 109 | - name: TZ 110 | value: "America/Sao_Paulo" 111 | - name: COUCHDB_USER 112 | value: "hyperledgeruser" 113 | - name: COUCHDB_PASSWORD 114 | value: "hyperledgerpass" 115 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org4peer1_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-org4peer1 5 | labels: 6 | run: blockchain-org4peer1 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: org4peer1 11 | ports: 12 | - protocol: TCP 13 | port: 30110 14 | name: grpc 15 | - protocol: TCP 16 | port: 30111 17 | name: events 18 | - protocol: TCP 19 | port: 5984 20 | name: couchdb 21 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org4peer2_deploy.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: Deployment 3 | metadata: 4 | name: blockchain-org4peer2 5 | spec: 6 | replicas: 1 7 | template: 8 | metadata: 9 | labels: 10 | name: org4peer2 11 | spec: 12 | volumes: 13 | - name: fabricfiles 14 | persistentVolumeClaim: 15 | claimName: fabric-pvc 16 | - name: dockersocket 17 | hostPath: 18 | path: /var/run/docker.sock 19 | 20 | containers: 21 | - name: peer 22 | image: hyperledger/fabric-peer:amd64-1.3.0 23 | command: ["sh", "-c", "peer node start"] 24 | env: 25 | - name: TZ 26 | value: "America/Sao_Paulo" 27 | - name: CORE_PEER_ADDRESSAUTODETECT 28 | value: "true" 29 | - name: CORE_PEER_ID 30 | value: blockchain-org4peer2 31 | - name: CORE_PEER_NETWORKID 32 | value: nid1 33 | - name: CORE_PEER_ADDRESS 34 | value: blockchain-org4peer2:30110 35 | - name: CORE_PEER_LISTENADDRESS 36 | value: 0.0.0.0:30110 37 | - name: CORE_PEER_EVENTS_ADDRESS 38 | value: 0.0.0.0:30111 39 | - name: CORE_PEER_GOSSIP_BOOTSTRAP 40 | value: blockchain-org4peer2:30110 41 | - name: CORE_PEER_GOSSIP_ENDPOINT 42 | value: blockchain-org4peer2:30110 43 | - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT 44 | value: blockchain-org4peer2:30110 45 | - name: CORE_PEER_GOSSIP_ORGLEADER 46 | value: "false" 47 | - name: CORE_PEER_GOSSIP_USELEADERELECTION 48 | value: "true" 49 | - name: CORE_PEER_GOSSIP_SKIPHANDSHAKE 50 | value: "false" 51 | - name: CORE_PEER_COMMITTER_ENABLED 52 | value: "true" 53 | - name: CORE_PEER_PROFILE_ENABLED 54 | value: "true" 55 | - name: CORE_VM_ENDPOINT 56 | value: unix:///host/var/run/docker.sock 57 | - name: CORE_PEER_LOCALMSPID 58 | value: Org4MSP 59 | - name: CORE_PEER_MSPCONFIGPATH 60 | value: /fabric/crypto-config/peerOrganizations/org4.example.com/peers/peer1.org4.example.com/msp/ 61 | - name: CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN 62 | value: "pbft" 63 | - name: CORE_PBFT_GENERAL_MODE 64 | value: "classic" 65 | - name: CORE_PBFT_GENERAL_N 66 | value: "4" 67 | - name: CORE_LOGGING_LEVEL 68 | value: debug 69 | - name: CORE_LOGGING_PEER 70 | value: debug 71 | - name: CORE_LOGGING_CAUTHDSL 72 | value: debug 73 | - name: CORE_LOGGING_GOSSIP 74 | value: debug 75 | - name: CORE_LOGGING_LEDGER 76 | value: debug 77 | - name: CORE_LOGGING_MSP 78 | value: debug 79 | - name: CORE_LOGGING_POLICIES 80 | value: debug 81 | - name: CORE_LOGGING_GRPC 82 | value: debug 83 | - name: CORE_PEER_TLS_ENABLED 84 | value: "false" 85 | - name: CORE_LEDGER_STATE_STATEDATABASE 86 | value: "CouchDB" 87 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS 88 | value: "localhost:5984" 89 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME 90 | value: "hyperledgeruser" 91 | - name: CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD 92 | value: "hyperledgerpass" 93 | - name: FABRIC_CFG_PATH 94 | value: /etc/hyperledger/fabric/ 95 | - name: ORDERER_URL 96 | value: blockchain-orderer:31010 97 | - name: GODEBUG 98 | value: "netdns=go" 99 | - name: CORE_VM_DOCKER_ATTACHSTDOUT 100 | value: "true" 101 | volumeMounts: 102 | - mountPath: /fabric 103 | name: fabricfiles 104 | - mountPath: /host/var/run/docker.sock 105 | name: dockersocket 106 | - name: couchdb 107 | image: hyperledger/fabric-couchdb:amd64-0.4.14 108 | env: 109 | - name: TZ 110 | value: "America/Sao_Paulo" 111 | - name: COUCHDB_USER 112 | value: "hyperledgeruser" 113 | - name: COUCHDB_PASSWORD 114 | value: "hyperledgerpass" 115 | -------------------------------------------------------------------------------- /kubernetes/blockchain-org4peer2_svc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: blockchain-org4peer2 5 | labels: 6 | run: blockchain-org4peer2 7 | spec: 8 | type: ClusterIP 9 | selector: 10 | name: org4peer2 11 | ports: 12 | - protocol: TCP 13 | port: 30110 14 | name: grpc 15 | - protocol: TCP 16 | port: 30111 17 | name: events 18 | - protocol: TCP 19 | port: 5984 20 | name: couchdb 21 | -------------------------------------------------------------------------------- /kubernetes/fabric-pv.yaml: -------------------------------------------------------------------------------- 1 | kind: PersistentVolume 2 | apiVersion: v1 3 | metadata: 4 | name: fabric-pv 5 | labels: 6 | type: local 7 | name: fabricfiles 8 | spec: 9 | capacity: 10 | storage: 10Gi 11 | volumeMode: Filesystem 12 | accessModes: 13 | - ReadWriteMany 14 | persistentVolumeReclaimPolicy: Retain 15 | nfs: 16 | path: /nfs/fabric 17 | server: storage.local.parisi.biz 18 | readOnly: false 19 | -------------------------------------------------------------------------------- /kubernetes/fabric-pvc.yaml: -------------------------------------------------------------------------------- 1 | kind: PersistentVolumeClaim 2 | apiVersion: v1 3 | metadata: 4 | name: fabric-pvc 5 | spec: 6 | accessModes: 7 | - ReadWriteMany 8 | resources: 9 | requests: 10 | storage: 10Gi 11 | selector: 12 | matchLabels: 13 | name: fabricfiles 14 | -------------------------------------------------------------------------------- /kubernetes/fabric-tools.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: fabric-tools 5 | spec: 6 | volumes: 7 | - name: fabricfiles 8 | persistentVolumeClaim: 9 | claimName: fabric-pvc 10 | - name: dockersocket 11 | hostPath: 12 | path: /var/run/docker.sock 13 | containers: 14 | - name: fabrictools 15 | image: hyperledger/fabric-tools:amd64-1.3.0 16 | imagePullPolicy: Always 17 | command: ["sh", "-c", "sleep 48h"] 18 | env: 19 | - name: TZ 20 | value: "America/Sao_Paulo" 21 | - name: FABRIC_CFG_PATH 22 | value: "/fabric" 23 | volumeMounts: 24 | - mountPath: /fabric 25 | name: fabricfiles 26 | - mountPath: /host/var/run/docker.sock 27 | name: dockersocket 28 | --------------------------------------------------------------------------------