---
apiVersion: batch/v1
kind: Job
metadata:
  name: joinchannel
spec:
  backoffLimit: 1
  template:
    metadata:
      name: joinchannel
    spec:
      restartPolicy: "Never"
      volumes:
      - name: sharedvolume
        persistentVolumeClaim:
          claimName: shared-pvc
      containers:
      - name: joinchannel1
        image: hyperledger/fabric-peer:1.4
        imagePullPolicy: Always
        command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} --tls --cafile /shared/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem ${CHANNEL_NAME}_0.block && peer channel join -b ${CHANNEL_NAME}_0.block"]
        env:
        - name: CHANNEL_NAME
          value: example
        - name: CORE_PEER_NETWORKID
          value: nid1
        - name: ORDERER_URL
          value: orderer:31010
        - name: CORE_PEER_ADDRESS
          value: org1peer0:30410
        - name: CORE_PEER_LOCALMSPID
          value: Org1MSP
        - name: CORE_PEER_MSPID
          value: Org1MSP
        - name: FABRIC_LOGGING_SPECL
          value: debug
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - 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: joinchannel1-1
        image: hyperledger/fabric-peer:1.4
        imagePullPolicy: Always
        command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} --tls --cafile /shared/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem ${CHANNEL_NAME}_0.block && peer channel join -b ${CHANNEL_NAME}_0.block"]
        env:
        - name: CHANNEL_NAME
          value: example
        - name: CORE_PEER_NETWORKID
          value: nid1
        - name: ORDERER_URL
          value: orderer:31010
        - name: CORE_PEER_ADDRESS
          value: org1peer1:30420
        - name: CORE_PEER_LOCALMSPID
          value: Org2MSP
        - name: CORE_PEER_MSPID
          value: Org1MSP
        - name: FABRIC_LOGGING_SPEC
          value: debug
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - 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: joinchannel2
        image: hyperledger/fabric-peer:1.4
        imagePullPolicy: Always
        command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} --tls --cafile /shared/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem ${CHANNEL_NAME}_0.block && peer channel join -b ${CHANNEL_NAME}_0.block"]
        env:
        - name: CHANNEL_NAME
          value: example
        - name: CORE_PEER_NETWORKID
          value: nid1
        - name: ORDERER_URL
          value: orderer:31010
        - name: CORE_PEER_ADDRESS
          value: org2peer0:30510
        - name: CORE_PEER_LOCALMSPID
          value: Org2MSP
        - name: CORE_PEER_MSPID
          value: Org2MSP
        - name: FABRIC_LOGGING_SPEC
          value: debug
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - 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: joinchannel2-1
        image: hyperledger/fabric-peer:1.4
        imagePullPolicy: Always
        command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} --tls --cafile /shared/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem ${CHANNEL_NAME}_0.block && peer channel join -b ${CHANNEL_NAME}_0.block"]
        env:
        - name: CHANNEL_NAME
          value: example
        - name: CORE_PEER_NETWORKID
          value: nid1
        - name: ORDERER_URL
          value: orderer:31010
        - name: CORE_PEER_ADDRESS
          value: org2peer1:30520
        - name: CORE_PEER_LOCALMSPID
          value: Org2MSP
        - name: CORE_PEER_MSPID
          value: Org2MSP
        - name: FABRIC_LOGGING_SPEC
          value: debug
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - 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: joinchannel3
        image: hyperledger/fabric-peer:1.4
        imagePullPolicy: Always
        command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} --tls --cafile /shared/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem ${CHANNEL_NAME}_0.block && peer channel join -b ${CHANNEL_NAME}_0.block"]
        env:
        - name: CHANNEL_NAME
          value: example
        - name: CORE_PEER_NETWORKID
          value: nid1
        - name: ORDERER_URL
          value: orderer:31010
        - name: CORE_PEER_ADDRESS
          value: org3peer0:30610
        - name: CORE_PEER_LOCALMSPID
          value: Org3MSP
        - name: CORE_PEER_MSPID
          value: Org3MSP
        - name: FABRIC_LOGGING_SPEC
          value: debug
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - 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: joinchannel3-1
        image: hyperledger/fabric-peer:1.4
        imagePullPolicy: Always
        command: ["sh", "-c", "peer channel fetch newest -o ${ORDERER_URL} -c ${CHANNEL_NAME} --tls --cafile /shared/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem ${CHANNEL_NAME}_0.block && peer channel join -b ${CHANNEL_NAME}_0.block"]
        env:
        - name: CHANNEL_NAME
          value: example
        - name: CORE_PEER_NETWORKID
          value: nid1
        - name: ORDERER_URL
          value: orderer:31010
        - name: CORE_PEER_ADDRESS
          value: org3peer1:30620
        - name: CORE_PEER_LOCALMSPID
          value: Org3MSP
        - name: CORE_PEER_MSPID
          value: Org3MSP
        - name: FABRIC_LOGGING_SPEC
          value: debug
        - name: CORE_PEER_MSPCONFIGPATH
          value: /shared/crypto-config/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
        - name: FABRIC_CFG_PATH
          value: /etc/hyperledger/fabric
        - 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

      

