---
apiVersion: batch/v1
kind: Job
metadata:
  namespace: org1
  name: createchannel
spec:
  backoffLimit: 1
  template:
    metadata:
      name: createchannel
    spec:
      restartPolicy: "Never"
      volumes:
        - name: sharedvolume
          persistentVolumeClaim:
            claimName: shared-pvc
      containers:
        - name: createchannel
          image: hyperledger/fabric-peer:2.0
          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:
            - name: CHANNEL_NAME
              value: mychannel
            - name: ORDERER_URL
              value: orderer0.ordererorg1:7050
            - name: CORE_PEER_ADDRESSAUTODETECT
              value: "false"
            - name: CORE_PEER_LOCALMSPID
              value: Org1MSP
            - name: CORE_PEER_MSPCONFIGPATH
              value: /shared/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/
            - name: FABRIC_LOGGING_SPEC
              value: debug
            - name: FABRIC_CFG_PATH
              value: /etc/hyperledger/fabric
            - name: GODEBUG
              value: "netdns=go"
          volumeMounts:
            - mountPath: /shared
              name: sharedvolume
