diff --git a/configFiles/chaincode_install.yaml b/configFiles/chaincode_install.yaml index fdd088b..05468d5 100644 --- a/configFiles/chaincode_install.yaml +++ b/configFiles/chaincode_install.yaml @@ -16,7 +16,7 @@ spec: claimName: shared-pvc containers: - name: chaincodeinstall1 - image: hyperledger/fabric-tools:1.2.1 + image: hyperledger/fabric-tools:1.4 imagePullPolicy: Always command: ["sh", "-c", "echo $GOPATH; cp -r /shared/artifacts/chaincode $GOPATH/src/; ls $GOPATH/src; peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/"] env: @@ -39,7 +39,7 @@ spec: name: sharedvolume - name: chaincodeinstall2 - image: hyperledger/fabric-tools:1.2.1 + image: hyperledger/fabric-tools:1.4 imagePullPolicy: Always command: ["sh", "-c", "echo $GOPATH; cp -r /shared/artifacts/chaincode $GOPATH/src/; ls $GOPATH/src; peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/"] env: @@ -62,7 +62,7 @@ spec: name: sharedvolume - name: chaincodeinstall3 - image: hyperledger/fabric-tools:1.2.1 + image: hyperledger/fabric-tools:1.4 imagePullPolicy: Always command: ["sh", "-c", "echo $GOPATH; cp -r /shared/artifacts/chaincode $GOPATH/src/; ls $GOPATH/src; peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/"] env: @@ -85,7 +85,7 @@ spec: name: sharedvolume - name: chaincodeinstall4 - image: hyperledger/fabric-tools:1.2.1 + image: hyperledger/fabric-tools:1.4 imagePullPolicy: Always command: ["sh", "-c", "echo $GOPATH; cp -r /shared/artifacts/chaincode $GOPATH/src/; ls $GOPATH/src; peer chaincode install -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -p chaincode_example02/"] env: diff --git a/configFiles/chaincode_instantiate.yaml b/configFiles/chaincode_instantiate.yaml index 1761cb5..7149d65 100644 --- a/configFiles/chaincode_instantiate.yaml +++ b/configFiles/chaincode_instantiate.yaml @@ -17,7 +17,7 @@ spec: containers: - name: chaincodeinstantiate - image: hyperledger/fabric-tools:1.2.1 + image: hyperledger/fabric-tools:1.4 imagePullPolicy: Always command: ["sh", "-c", "peer chaincode instantiate -o blockchain-orderer:31010 -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -c '{\"Args\":[\"init\",\"a\",\"100\",\"b\",\"200\"]}'"] env: diff --git a/configFiles/createVolume-azure.yaml b/configFiles/createVolume-azure.yaml new file mode 100644 index 0000000..9bbab75 --- /dev/null +++ b/configFiles/createVolume-azure.yaml @@ -0,0 +1,51 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: system:azure-cloud-provider +rules: +- apiGroups: [''] + resources: ['secrets'] + verbs: ['get','create'] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: system:azure-cloud-provider +roleRef: + kind: ClusterRole + apiGroup: rbac.authorization.k8s.io + name: system:azure-cloud-provider +subjects: +- kind: ServiceAccount + name: persistent-volume-binder + namespace: kube-system + +--- +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: azurefile +provisioner: kubernetes.io/azure-file +mountOptions: + - dir_mode=0777 + - file_mode=0777 + - uid=1000 + - gid=1000 +parameters: + skuName: Standard_LRS + storageAccount: bcfabricstorage + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: shared-pvc +spec: + accessModes: + - ReadWriteMany + storageClassName: azurefile + resources: + requests: + storage: 5Gi \ No newline at end of file diff --git a/configFiles/createVolume.yaml b/configFiles/createVolume.yaml index a2b7033..08ba4fe 100644 --- a/configFiles/createVolume.yaml +++ b/configFiles/createVolume.yaml @@ -1,19 +1,3 @@ ---- -kind: PersistentVolume -apiVersion: v1 -metadata: - name: shared-pv - labels: - type: local - name: sharedvolume -spec: - capacity: - storage: 1Gi - accessModes: - - ReadWriteMany - hostPath: - path: "/tmp" - --- kind: PersistentVolumeClaim apiVersion: v1 @@ -26,6 +10,3 @@ spec: requests: storage: 1Gi storageClassName: "" - selector: - matchLabels: - name: sharedvolume diff --git a/configFiles/create_channel.yaml b/configFiles/create_channel.yaml index 20bae50..4bf1ece 100644 --- a/configFiles/create_channel.yaml +++ b/configFiles/create_channel.yaml @@ -16,7 +16,7 @@ spec: claimName: shared-pvc containers: - name: createchanneltx - image: hyperledger/fabric-tools:1.2.1 + image: hyperledger/fabric-tools:1.4 imagePullPolicy: Always command: ["sh", "-c", "cd /shared && pwd && ls && export FABRIC_CFG_PATH=$PWD && configtxgen -profile FourOrgsChannel -outputCreateChannelTx ${CHANNEL_NAME}.tx -channelID ${CHANNEL_NAME} && touch /shared/status_channeltx_complete "] env: @@ -29,7 +29,7 @@ spec: name: sharedvolume - name: createchannel - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 imagePullPolicy: Always command: ["sh", "-c", "while [ ! -f /shared/status_channeltx_complete ]; do echo Waiting for channeltx; sleep 2; done; peer channel create -o ${ORDERER_URL} -c ${CHANNEL_NAME} -f /shared/${CHANNEL_NAME}.tx && rm /shared/status_channeltx_complete && touch /shared/status_channelcreate_complete"] env: diff --git a/configFiles/generateArtifactsJob.yaml b/configFiles/generateArtifactsJob.yaml index cae471c..9ecc2bb 100644 --- a/configFiles/generateArtifactsJob.yaml +++ b/configFiles/generateArtifactsJob.yaml @@ -19,14 +19,14 @@ spec: path: /var/run/docker.sock containers: - name: cryptogen - image: hyperledger/fabric-tools:1.2.1 + image: hyperledger/fabric-tools:1.4 imagePullPolicy: Always command: ["sh", "-c", "echo 'Cryptogen Starts'; ls -l /shared/artifacts; while [ ! -d /shared/artifacts ]; do echo Waiting for configFiles; sleep 1; done; cryptogen generate --config /shared/artifacts/crypto-config.yaml && cp -r crypto-config /shared/ && for file in $(find /shared/ -iname *_sk); do echo $file; dir=$(dirname $file); echo ${dir}; mv ${dir}/*_sk ${dir}/key.pem; done && find /shared -type d | xargs chmod a+rx && find /shared -type f | xargs chmod a+r && touch /shared/status_cryptogen_complete;"] volumeMounts: - mountPath: /shared name: sharedvolume - name: configtxgen - image: hyperledger/fabric-tools:1.2.1 + image: hyperledger/fabric-tools:1.4 imagePullPolicy: Always command: ["sh", "-c", "echo 'Configtxgen Starts'; ls -l /shared; sleep 1 && while [ ! -f /shared/status_cryptogen_complete ]; do echo Waiting for cryptogen; sleep 1; done; cp /shared/artifacts/configtx.yaml /shared/; cd /shared/; export FABRIC_CFG_PATH=$PWD; configtxgen -profile FourOrgsOrdererGenesis -outputBlock genesis.block && find /shared -type d | xargs chmod a+rx && find /shared -type f | xargs chmod a+r && touch /shared/status_configtxgen_complete && rm /shared/status_cryptogen_complete;"] volumeMounts: diff --git a/configFiles/join_channel.yaml b/configFiles/join_channel.yaml index b8340d4..294894c 100644 --- a/configFiles/join_channel.yaml +++ b/configFiles/join_channel.yaml @@ -16,7 +16,7 @@ spec: claimName: shared-pvc containers: - name: joinchannel1 - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 imagePullPolicy: Always command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} && peer channel join -b ${CHANNEL_NAME}_newest.block "] env: @@ -45,7 +45,7 @@ spec: name: sharedvolume - name: joinchannel2 - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 imagePullPolicy: Always command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} && peer channel join -b ${CHANNEL_NAME}_newest.block "] env: @@ -74,7 +74,7 @@ spec: name: sharedvolume - name: joinchannel3 - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 imagePullPolicy: Always command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} && peer channel join -b ${CHANNEL_NAME}_newest.block "] env: @@ -103,7 +103,7 @@ spec: name: sharedvolume - name: joinchannel4 - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 imagePullPolicy: Always command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} && peer channel join -b ${CHANNEL_NAME}_newest.block "] env: diff --git a/configFiles/peersDeployment.yaml b/configFiles/peersDeployment.yaml index b9cb8b4..821c143 100644 --- a/configFiles/peersDeployment.yaml +++ b/configFiles/peersDeployment.yaml @@ -17,7 +17,7 @@ spec: containers: - name: orderer - image: hyperledger/fabric-orderer:1.2.1 + image: hyperledger/fabric-orderer:1.4 command: ["sh", "-c", "sleep 5 && while [ ! -f /shared/status_configtxgen_complete ]; do echo Waiting for configtxgen; sleep 1; done; orderer"] env: - name: ORDERER_CFG_PATH @@ -77,7 +77,7 @@ spec: containers: - name: ca - image: hyperledger/fabric-ca:1.2.1 + image: hyperledger/fabric-ca:1.4 command: ["sh", "-c", "sleep 1 && while [ ! -f /shared/status_configtxgen_complete ]; do echo Waiting for configtxgen; sleep 1; done; fabric-ca-server start -b admin:adminpw -d"] env: - name: FABRIC_CA_SERVER_CA_NAME @@ -122,7 +122,7 @@ spec: containers: - name: org1peer1 - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 command: ["sh", "-c", "sleep 1 && while [ ! -f /shared/status_configtxgen_complete ]; do echo Waiting for configtxgen; sleep 1; done; peer node start"] env: - name: CORE_PEER_ADDRESSAUTODETECT @@ -208,7 +208,7 @@ spec: containers: - name: org2peer1 - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 command: ["sh", "-c", "sleep 1 && while [ ! -f /shared/status_configtxgen_complete ]; do echo Waiting for configtxgen; sleep 1; done; peer node start"] env: - name: CORE_PEER_ADDRESSAUTODETECT @@ -295,7 +295,7 @@ spec: containers: - name: org3peer1 - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 command: ["sh", "-c", "sleep 1 && while [ ! -f /shared/status_configtxgen_complete ]; do echo Waiting for configtxgen; sleep 1; done; peer node start"] env: - name: CORE_PEER_ADDRESSAUTODETECT @@ -382,7 +382,7 @@ spec: containers: - name: org4peer1 - image: hyperledger/fabric-peer:1.2.1 + image: hyperledger/fabric-peer:1.4 command: ["sh", "-c", "sleep 1 && while [ ! -f /shared/status_configtxgen_complete ]; do echo Waiting for configtxgen; sleep 1; done; peer node start"] env: - name: CORE_PEER_ADDRESSAUTODETECT diff --git a/setup_blockchainNetwork.sh b/setup_blockchainNetwork.sh index 5801e05..ec59a5a 100644 --- a/setup_blockchainNetwork.sh +++ b/setup_blockchainNetwork.sh @@ -41,9 +41,16 @@ if [ "$(kubectl get pvc | grep shared-pvc | awk '{print $2}')" != "Bound" ]; the kubectl create -f ${KUBECONFIG_FOLDER}/createVolume-paid.yaml sleep 5 else - echo "Running: kubectl create -f ${KUBECONFIG_FOLDER}/createVolume.yaml" - kubectl create -f ${KUBECONFIG_FOLDER}/createVolume.yaml - sleep 5 + if [ "$1" == "--azure" ]; then + echo "You passed argument --azure. Make sure you have an Azure Kubernetes Cluster. Else, remove --azure option" + echo "Running: kubectl create -f ${KUBECONFIG_FOLDER}/createVolume-azure.yaml" + kubectl create -f ${KUBECONFIG_FOLDER}/createVolume-azure.yaml + sleep 5 + else + echo "Running: kubectl create -f ${KUBECONFIG_FOLDER}/createVolume.yaml" + kubectl create -f ${KUBECONFIG_FOLDER}/createVolume.yaml + sleep 5 + fi fi if [ "kubectl get pvc | grep shared-pvc | awk '{print $3}'" != "shared-pv" ]; then