---
apiVersion: batch/v1
kind: Job
metadata:
  name: chaincodeinstantiate
spec:
  backoffLimit: 1
  template:
    metadata:
      name: chaincodeinstantiate
    spec:
      restartPolicy: "Never"
      volumes:
      - name: sharedvolume
        persistentVolumeClaim:
          claimName: shared-pvc

      containers:
      - name: chaincodeinstantiate
        image: hyperledger/fabric-tools:1.2.1
        imagePullPolicy: Always
        command: ["sh", "-c", "peer chaincode instantiate -o blockchain-orderer:31010 -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -l node -v ${CHAINCODE_VERSION} -c '{\"Args\":[\"\"]}' -P \"OR ('Org1MSP.member','Org2MSP.member')\""]
        env:
        - name: CHANNEL_NAME
          value: channel1
        - name: CHAINCODE_NAME
          value: "cc"
        - 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: blockchain-org1peer1:30110
        - name: GODEBUG
          value: "netdns=go"
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume
