From 1493dfaa38cdc894b2d57825c751e0ab64b85924 Mon Sep 17 00:00:00 2001 From: Connor Christie Date: Fri, 18 Jan 2019 13:52:50 -0600 Subject: [PATCH 1/4] Update to Fabric 1.4 LTS --- configFiles/chaincode_install.yaml | 8 ++++---- configFiles/chaincode_instantiate.yaml | 2 +- configFiles/createVolume-paid.yaml | 4 ++-- configFiles/createVolume.yaml | 23 ++--------------------- configFiles/create_channel.yaml | 4 ++-- configFiles/generateArtifactsJob.yaml | 4 ++-- configFiles/join_channel.yaml | 8 ++++---- configFiles/peersDeployment.yaml | 12 ++++++------ deleteNetwork.sh | 0 setup_blockchainNetwork.sh | 0 10 files changed, 23 insertions(+), 42 deletions(-) mode change 100644 => 100755 deleteNetwork.sh mode change 100644 => 100755 setup_blockchainNetwork.sh 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-paid.yaml b/configFiles/createVolume-paid.yaml index 2a3a6e4..1a3474f 100644 --- a/configFiles/createVolume-paid.yaml +++ b/configFiles/createVolume-paid.yaml @@ -9,5 +9,5 @@ spec: - ReadWriteMany resources: requests: - storage: 20Gi - storageClassName: "ibmc-file-bronze" + storage: 5Gi + storageClassName: managed-premium diff --git a/configFiles/createVolume.yaml b/configFiles/createVolume.yaml index a2b7033..ae93350 100644 --- a/configFiles/createVolume.yaml +++ b/configFiles/createVolume.yaml @@ -1,31 +1,12 @@ --- -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 metadata: name: shared-pvc spec: accessModes: - ReadWriteMany + storageClassName: azurefile resources: requests: - storage: 1Gi - storageClassName: "" - selector: - matchLabels: - name: sharedvolume + storage: 5Gi \ No newline at end of file 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/deleteNetwork.sh b/deleteNetwork.sh old mode 100644 new mode 100755 diff --git a/setup_blockchainNetwork.sh b/setup_blockchainNetwork.sh old mode 100644 new mode 100755 From f04dcbcac7c85aa53b8d0b9c5e829fc670861397 Mon Sep 17 00:00:00 2001 From: Connor Christie Date: Fri, 18 Jan 2019 13:56:56 -0600 Subject: [PATCH 2/4] Add Azure storage option --- azure-storage-class.yaml | 38 +++++++++++++++++++++ configFiles/createVolume-azure.yaml | 51 +++++++++++++++++++++++++++++ configFiles/createVolume-paid.yaml | 4 +-- configFiles/createVolume.yaml | 6 ++-- deleteNetwork.sh | 0 setup_blockchainNetwork.sh | 0 6 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 azure-storage-class.yaml create mode 100644 configFiles/createVolume-azure.yaml mode change 100755 => 100644 deleteNetwork.sh mode change 100755 => 100644 setup_blockchainNetwork.sh diff --git a/azure-storage-class.yaml b/azure-storage-class.yaml new file mode 100644 index 0000000..f9f1498 --- /dev/null +++ b/azure-storage-class.yaml @@ -0,0 +1,38 @@ +--- +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 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-paid.yaml b/configFiles/createVolume-paid.yaml index 1a3474f..2a3a6e4 100644 --- a/configFiles/createVolume-paid.yaml +++ b/configFiles/createVolume-paid.yaml @@ -9,5 +9,5 @@ spec: - ReadWriteMany resources: requests: - storage: 5Gi - storageClassName: managed-premium + storage: 20Gi + storageClassName: "ibmc-file-bronze" diff --git a/configFiles/createVolume.yaml b/configFiles/createVolume.yaml index ae93350..08ba4fe 100644 --- a/configFiles/createVolume.yaml +++ b/configFiles/createVolume.yaml @@ -1,12 +1,12 @@ --- -apiVersion: v1 kind: PersistentVolumeClaim +apiVersion: v1 metadata: name: shared-pvc spec: accessModes: - ReadWriteMany - storageClassName: azurefile resources: requests: - storage: 5Gi \ No newline at end of file + storage: 1Gi + storageClassName: "" diff --git a/deleteNetwork.sh b/deleteNetwork.sh old mode 100755 new mode 100644 diff --git a/setup_blockchainNetwork.sh b/setup_blockchainNetwork.sh old mode 100755 new mode 100644 From 5360c503700cc085f0bfe7bab296e1174ebcc644 Mon Sep 17 00:00:00 2001 From: Connor Christie Date: Fri, 18 Jan 2019 13:58:37 -0600 Subject: [PATCH 3/4] Add azure option in setup --- setup_blockchainNetwork.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 From bc7b8a38e24f30488797e9c1bb36893a43db6eb6 Mon Sep 17 00:00:00 2001 From: Connor Christie Date: Fri, 18 Jan 2019 13:59:52 -0600 Subject: [PATCH 4/4] Remove unnecessary Azure storage class file --- azure-storage-class.yaml | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 azure-storage-class.yaml diff --git a/azure-storage-class.yaml b/azure-storage-class.yaml deleted file mode 100644 index f9f1498..0000000 --- a/azure-storage-class.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- -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