apiVersion: apps/v1
kind: Deployment
metadata:
  name: peer0-org1-network1
spec:
  replicas: 1
  selector:
    matchLabels:
      name: peer0-org1-network1
  template:
    metadata:
      labels:
        name: peer0-org1-network1
        app: peer0-org1-network1
    spec:
      volumes:
        - name: network1-secrets
          persistentVolumeClaim:
            claimName: network1-secrets
        - name: external-builder
          configMap:
            name: external-builder
            defaultMode: 0777
        - name: peer-config
          configMap:
            name: peer-config
      containers:
        - name: peers
          image: hyperledger/fabric-peer:2.1
          command: ["sh", "-c", "apk add --no-cache bash jq;
                        peer node start"]
          ports:
            - containerPort: 7051
            - containerPort: 7052
            - containerPort: 7053
          env:
            - name: FABRIC_LOGGING_SPEC
              value: INFO
            - name: FABRIC_CFG_PATH
              value: /etc/hyperledger/fabric
            - name: CORE_PEER_ID
              value: peer0-org1-network1
            - name: CORE_PEER_ADDRESS
              value: peer0-org1-network1:7051
            - name: CORE_PEER_LISTENADDRESS
              value: 0.0.0.0:7051
            - name: CORE_PEER_CHAINCODEADDRESS
              value: peer0-org1-network1:7052
            - name: CORE_PEER_CHAINCODELISTENADDRESS
              value: 0.0.0.0:7052
            - name: CORE_PEER_GOSSIP_BOOTSTRAP
              value: peer0-org1-network1:7051
            - name: CORE_PEER_GOSSIP_ENDPOINT
              value: peer0-org1-network1:7051
            - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT
              value: peer0-org1-network1:7051
            - name: CORE_PEER_GOSSIP_ORGLEADER
              value: "false"
            - name: CORE_PEER_GOSSIP_USELEADERELECTION
              value: "true"
            - name: CORE_PEER_PROFILE_ENABLED
              value: "true"
            - name: CORE_PEER_LOCALMSPID
              value: Org1MSP
            - name: CORE_PEER_MSPCONFIGPATH
              value: /fabric/peer/msp
            - name: CORE_PEER_TLS_ENABLED
              value: "true"
            - name: CORE_PEER_PROFILE_ENABLED
              value: "true"
            - name: CORE_PEER_TLS_KEY_FILE
              value: /fabric/peer/tls/server.key
            - name: CORE_PEER_TLS_CERT_FILE
              value: /fabric/peer/tls/server.crt
            - name: CORE_PEER_TLS_ROOTCERT_FILE
              value: /fabric/peer/tls/ca.crt
            - name: CORE_LEDGER_STATE_DATABASE
              value: "CouchDB"
            - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS
              value: "localhost:5984"
            - name: ORDERER_URL
              value: ord0-orderers-network1:7050
          volumeMounts:
            - name: network1-secrets
              subPath: peerOrganizations/org1/peers/peer0-org1-network1
              mountPath: /fabric/peer
            - name: network1-secrets
              mountPath: /fabric/network1-secrets
            - name: external-builder
              mountPath: /fabric/external-service-builder/bin
            - name: peer-config
              mountPath: /etc/hyperledger/fabric
        - name: couchdb
          image: hyperledger/fabric-couchdb
          ports:
            - containerPort: 5984

# ---
# apiVersion: apps/v1
# kind: Deployment
# metadata:
#   name: peer0-org2-network1
# spec:
#   replicas: 1
#   selector:
#     matchLabels:
#       name: peer0-org2-network1
#   template:
#     metadata:
#       labels:
#         name: peer0-org2-network1
#         app: peer0-org2-network1
#     spec:
#       volumes:
#         - name: network1-secrets
#           persistentVolumeClaim:
#             claimName: network1-secrets
#       containers:
#         - name: peers
#           image: hyperledger/fabric-peer:2.1
#           command: ["sh", "-c", "peer node start"]
#           ports:
#             - containerPort: 7051
#             - containerPort: 7052
#             - containerPort: 7061
#           env:
#             - name: CORE_VM_ENDPOINT
#               value: unix:///host/var/run/docker.sock
#             - name: FABRIC_LOGGING_SPEC
#               value: INFO
#             - name: FABRIC_CFG_PATH
#               value: /etc/hyperledger/fabric
#             - name: CORE_PEER_ID
#               value: peer0-org2-network1
#             - name: CORE_PEER_ADDRESS
#               value: peer0-org2-network1:7051
#             - name: CORE_PEER_LISTENADDRESS
#               value: 0.0.0.0:7051
#             - name: CORE_PEER_EVENTS_ADDRESS
#               value: 0.0.0.0:7061
#             - name: CORE_PEER_CHAINCODEADDRESS
#               value: peer0-org2-network1:7052
#             - name: CORE_PEER_CHAINCODELISTENADDRESS
#               value: 0.0.0.0:7052
#             - name: CORE_PEER_GOSSIP_BOOTSTRAP
#               value: peer0-org2-network1:7051
#             - name: CORE_PEER_GOSSIP_ENDPOINT
#               value: peer0-org2-network1:7051
#             - name: CORE_PEER_GOSSIP_EXTERNALENDPOINT
#               value: peer0-org2-network1:7051
#             - name: CORE_PEER_GOSSIP_ORGLEADER
#               value: "false"
#             - name: CORE_PEER_GOSSIP_USELEADERELECTION
#               value: "true"
#             - name: CORE_PEER_PROFILE_ENABLED
#               value: "true"
#             - name: CORE_PEER_LOCALMSPID
#               value: Org2MSP
#             - name: CORE_PEER_MSPCONFIGPATH
#               value: /fabric/peer/msp
#             - name: CORE_PEER_TLS_ENABLED
#               value: "true"
#             - name: CORE_PEER_PROFILE_ENABLED
#               value: "true"
#             - name: CORE_PEER_TLS_KEY_FILE
#               value: /fabric/peer/tls/server.key
#             - name: CORE_PEER_TLS_CERT_FILE
#               value: /fabric/peer/tls/server.crt
#             - name: CORE_PEER_TLS_ROOTCERT_FILE
#               value: /fabric/peer/tls/ca.crt
#             - name: CORE_LEDGER_STATE_DATABASE
#               value: "CouchDB"
#             - name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS
#               value: "localhost:5984"
#             - name: ORDERER_URL
#               value: ord0-orderers-network1:7050
#           volumeMounts:
#             - name: network1-secrets
#               subPath: peerOrganizations/org2/peers/peer0-org2-network1
#               mountPath: /fabric/peer
#             - name: network1-secrets
#               mountPath: /fabric/network1-secrets
#         - name: couchdb
#           image: hyperledger/fabric-couchdb
#           ports:
#             - containerPort: 5984
