apiVersion: apps/v1
# apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  namespace: fabrick8s
  name: cli
spec:
  replicas: 1
  strategy: {}
  selector:
    matchLabels:
      name: cli  
  template:
    metadata:
      labels:
        name: cli
    spec:
      nodeSelector:
        id: peer
      containers:
        - name: cli
          image:  hyperledger/fabric-tools:latest
          env:
          - name: TZ
            value: "America/Chicago"
          - name: CORE_PEER_TLS_ENABLED
            value: "false"
          #- name: CORE_PEER_TLS_CERT_FILE
          #  value: /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1/peers/peer0.org1/tls/server.crt
          #- name: CORE_PEER_TLS_KEY_FILE
          #  value: /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1/peers/peer0.org1/tls/server.key
          #- name: CORE_PEER_TLS_ROOTCERT_FILE
          #  value: /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1/peers/peer0.org1/tls/ca.crt
          # - name: CORE_VM_ENDPOINT
            # value: unix:///host/var/run/docker.sock
          # - name: CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE
            # value: "bridge"
          - name: CORE_VM_ENDPOINT
            # value: tcp://docker:2375
            value: unix:///host/var/run/docker.sock
          - name: CORE_PEER_NETWORKID
            value: nid1
          - name: GOPATH
            value: "/opt/gopath"
          - name: FABRIC_LOGGING_SPEC
            value: "DEBUG"
          - name: CORE_PEER_ID
            value: "cli"
          - name: CORE_PEER_ADDRESS
            value: "peer0-org1:30001"
          - name: CORE_PEER_LOCALMSPID
            value: "Org1MSP"
          - name: CORE_PEER_MSPCONFIGPATH
            value: "/etc/hyperledger/fabric/msp"
          - name: FABRIC_CFG_PATH
            value: /etc/hyperledger/fabric/
          workingDir: /opt/gopath/src/github.com/hyperledger/fabric/peer
          command: [ "/bin/bash", "-c", "--" ]
          args: [ "while true; do sleep 30; done;" ]
          volumeMounts:
           - mountPath: /host/var/run/
             name: run
           - mountPath: /opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode
             name: chaincode
           - mountPath: /etc/hyperledger/fabric/msp
             name: certificate
             subPath: users/Admin@org1/msp
           - mountPath: /opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
             name: artifacts
           - mountPath: /host/var/run/docker.sock
             name: dockersocket

      volumes:
        - name: certificate
          persistentVolumeClaim:
              claimName: org1-pv
        - name: artifacts
          persistentVolumeClaim:
              claimName: org1-artifacts-pv
        - name: chaincode
          persistentVolumeClaim:
              claimName: org1-chaincode-pv
        - name: run
          hostPath:
            path: /var/run
        - name: dockersocket
          hostPath:
            path: /var/run/docker.sock
