---
apiVersion: batch/v1
kind: Job
metadata:
  name: chaincodeinstall
spec:
  backoffLimit: 1
  template:
    metadata:
      name: chaincodeinstall
    spec:
      restartPolicy: "Never"
      volumes:
      - name: sharedvolume
        persistentVolumeClaim:
          claimName: shared-pvc
      containers:
      - name: chaincodeinstall1
        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 mycc/"]
        env:
        - name: CHAINCODE_NAME
          value: "mycc"
        - name: CHAINCODE_VERSION
          value: "1.0"
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
        - name: CORE_PEER_LOCALMSPID
          value: Org1MSP
        - name: CORE_PEER_ADDRESS
          value: org1peer0:30410
        - name: CORE_PEER_TLS_ENABLED
          value: "true"
        - name: CORE_PEER_TLS_KEY_FILE
          value: /shared/crypto-config/peerOrganizations/org1.example.com/peers/org1peer0.org1.example.com/tls/server.key
        - name: CORE_PEER_TLS_CERT_FILE
          value: /shared/crypto-config/peerOrganizations/org1.example.com/peers/org1peer0.org1.example.com/tls/server.crt
        - name: CORE_PEER_TLS_ROOTCERT_FILE
          value: /shared/crypto-config/peerOrganizations/org1.example.com/peers/org1peer0.org1.example.com/tls/ca.crt
        - name: GODEBUG
          value: "netdns=go"
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume
      - name: chaincodeinstall1-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 mycc/"]
        env:
        - name: CHAINCODE_NAME
          value: "mycc"
        - name: CHAINCODE_VERSION
          value: "1.0"
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
        - name: CORE_PEER_LOCALMSPID
          value: Org1MSP
        - name: CORE_PEER_ADDRESS
          value: org1peer1:30420
        - name: CORE_PEER_TLS_ENABLED
          value: "true"
        - name: CORE_PEER_TLS_KEY_FILE
          value: /shared/crypto-config/peerOrganizations/org1.example.com/peers/org1peer1.org1.example.com/tls/server.key
        - name: CORE_PEER_TLS_CERT_FILE
          value: /shared/crypto-config/peerOrganizations/org1.example.com/peers/org1peer1.org1.example.com/tls/server.crt
        - name: CORE_PEER_TLS_ROOTCERT_FILE
          value: /shared/crypto-config/peerOrganizations/org1.example.com/peers/org1peer1.org1.example.com/tls/ca.crt
        - name: GODEBUG
          value: "netdns=go"
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume

      - name: chaincodeinstall2
        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 mycc/"]
        env:
        - name: CHAINCODE_NAME
          value: "mycc"
        - name: CHAINCODE_VERSION
          value: "1.0"
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
        - name: CORE_PEER_LOCALMSPID
          value: Org2MSP
        - name: CORE_PEER_ADDRESS
          value: org2peer0:30510
        - name: CORE_PEER_TLS_ENABLED
          value: "true"
        - name: CORE_PEER_TLS_KEY_FILE
          value: /shared/crypto-config/peerOrganizations/org2.example.com/peers/org2peer0.org2.example.com/tls/server.key
        - name: CORE_PEER_TLS_CERT_FILE
          value: /shared/crypto-config/peerOrganizations/org2.example.com/peers/org2peer0.org2.example.com/tls/server.crt
        - name: CORE_PEER_TLS_ROOTCERT_FILE
          value: /shared/crypto-config/peerOrganizations/org2.example.com/peers/org2peer0.org2.example.com/tls/ca.crt
        - name: GODEBUG
          value: "netdns=go"
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume
      - name: chaincodeinstall2-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 mycc/"]
        env:
        - name: CHAINCODE_NAME
          value: "mycc"
        - name: CHAINCODE_VERSION
          value: "1.0"
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
        - name: CORE_PEER_LOCALMSPID
          value: Org2MSP
        - name: CORE_PEER_ADDRESS
          value: org2peer1:30520
        - name: CORE_PEER_TLS_ENABLED
          value: "true"
        - name: CORE_PEER_TLS_KEY_FILE
          value: /shared/crypto-config/peerOrganizations/org2.example.com/peers/org2peer1.org2.example.com/tls/server.key
        - name: CORE_PEER_TLS_CERT_FILE
          value: /shared/crypto-config/peerOrganizations/org2.example.com/peers/org2peer1.org2.example.com/tls/server.crt
        - name: CORE_PEER_TLS_ROOTCERT_FILE
          value: /shared/crypto-config/peerOrganizations/org2.example.com/peers/org2peer1.org2.example.com/tls/ca.crt
        - name: GODEBUG
          value: "netdns=go"
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume

      - name: chaincodeinstall3
        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 mycc/"]
        env:
        - name: CHAINCODE_NAME
          value: "mycc"
        - name: CHAINCODE_VERSION
          value: "1.0"
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
        - name: CORE_PEER_LOCALMSPID
          value: Org3MSP
        - name: CORE_PEER_ADDRESS
          value: org3peer0:30610
        - name: CORE_PEER_TLS_ENABLED
          value: "true"
        - name: CORE_PEER_TLS_KEY_FILE
          value: /shared/crypto-config/peerOrganizations/org3.example.com/peers/org3peer0.org3.example.com/tls/server.key
        - name: CORE_PEER_TLS_CERT_FILE
          value: /shared/crypto-config/peerOrganizations/org3.example.com/peers/org3peer0.org3.example.com/tls/server.crt
        - name: CORE_PEER_TLS_ROOTCERT_FILE
          value: /shared/crypto-config/peerOrganizations/org3.example.com/peers/org3peer0.org3.example.com/tls/ca.crt
        - name: GODEBUG
          value: "netdns=go"
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume

      - name: chaincodeinstall3-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 mycc/"]
        env:
        - name: CHAINCODE_NAME
          value: "mycc"
        - name: CHAINCODE_VERSION
          value: "1.0"
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
        - name: CORE_PEER_LOCALMSPID
          value: Org3MSP
        - name: CORE_PEER_ADDRESS
          value: org3peer1:30620
        - name: CORE_PEER_TLS_ENABLED
          value: "true"
        - name: CORE_PEER_TLS_KEY_FILE
          value: /shared/crypto-config/peerOrganizations/org3.example.com/peers/org3peer1.org3.example.com/tls/server.key
        - name: CORE_PEER_TLS_CERT_FILE
          value: /shared/crypto-config/peerOrganizations/org3.example.com/peers/org3peer1.org3.example.com/tls/server.crt
        - name: CORE_PEER_TLS_ROOTCERT_FILE
          value: /shared/crypto-config/peerOrganizations/org3.example.com/peers/org3peer1.org3.example.com/tls/ca.crt
        - name: GODEBUG
          value: "netdns=go"
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume
