---
apiVersion: batch/v1
kind: Job
metadata:
  namespace: fabric
  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:x86_64-1.1.0
        command: ["sh", "-c", "peer chaincode instantiate -o ${ORDERER_URL} -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -v ${CHAINCODE_VERSION} -c '{\"Args\":[\"init\",\"a\",\"100\",\"b\",\"200\"]}'"]
        env:
        - name: CHANNEL_NAME
          value: mychannel
        - name: ORDERER_URL
          value: orderer0.ordererorg1:7050
        - 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/users/Admin@org1/msp
        - name: CORE_PEER_TLS_ROOTCERT_FILE
          value: /shared/crypto-config/peerOrganizations/org1/peers/peer0.org1/tls/ca.crt
        - name: CORE_PEER_LOCALMSPID
          value: Org1MSP
        - name: CORE_PEER_ADDRESS
          value: peer0.org1:7051
        - name: GODEBUG
          value: "netdns=go"
        volumeMounts:
        - mountPath: /shared
          name: sharedvolume
