Kubernetes 上的 Hyperledger Fabric 中的链代码构建失败

问题描述 投票:0回答:1

在 Kubernetes 中部署 Hyperledger Fabric v2.0

我正在尝试在Azure Cloud中运行的私有 Kubernetes 集群中部署示例链代码。创建节点然后运行安装链码操作失败并抛出以下错误。我只使用单个 Kubernetes 集群。

错误:

chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image inspection failed: cannot connect to Docker endpoint
command terminated with exit code 1

下面是 Deployment、Service 和 ConfigMap 的对等配置模板

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: ${PEER}
  name: ${PEER}
  namespace: ${ORG}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ${PEER}
  strategy: {}
  template:
    metadata:
      labels:
        app: ${PEER}
    spec:
      containers:
      - name: couchdb
        image: blockchainpractice.azurecr.io/hyperledger/fabric-couchdb
        env:
        - name: COUCHDB_USER
          value: couchdb
        - name: COUCHDB_PASSWORD
          value: couchdb
        ports:
        - containerPort: 5984
      - name: fabric-peer
        image: blockchainpractice.azurecr.io/hyperledger/fabric-peer:2.0
        resources: {}
        envFrom:
        - configMapRef:
            name: ${PEER}
        volumeMounts:
        - name: dockersocket 
          mountPath: "/host/var/run/docker.sock"
        - name: ${PEER}
          mountPath: "/etc/hyperledger/fabric-peer"
        - name: client-root-tlscas
          mountPath: "/etc/hyperledger/fabric-peer/client-root-tlscas"  
      volumes:
      - name: dockersocket
        hostPath:
          path: "/var/run/docker.sock"
      - name: ${PEER}
        secret:
          secretName: ${PEER}
          items:
          - key: key.pem
            path: msp/keystore/key.pem
          - key: cert.pem
            path: msp/signcerts/cert.pem
          - key: tlsca-cert.pem
            path: msp/tlsca/tlsca-cert.pem
          - key: ca-cert.pem
            path: msp/cacerts/ca-cert.pem
          - key: config.yaml
            path: msp/config.yaml
          - key: tls.crt
            path: tls/tls.crt
          - key: tls.key
            path: tls/tls.key
          - key: orderer-tlsca-cert.pem
            path: orderer-tlsca-cert.pem
          - key: core.yaml
            path: core.yaml
      - name: client-root-tlscas
        secret:
          secretName: client-root-tlscas
---
apiVersion: v1
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: ${PEER}
  namespace: ${ORG}
data:
  CORE_PEER_ADDRESSAUTODETECT: "true"
  CORE_PEER_ID: ${PEER}
  CORE_PEER_LISTENADDRESS: 0.0.0.0:7051
  CORE_PEER_PROFILE_ENABLED: "true"
  CORE_PEER_LOCALMSPID: ${ORG_MSP}
  CORE_PEER_MSPCONFIGPATH: /etc/hyperledger/fabric-peer/msp
  # Gossip
  CORE_PEER_GOSSIP_BOOTSTRAP: peer0.${ORG}:7051
  CORE_PEER_GOSSIP_EXTERNALENDPOINT: "${PEER}.${ORG}:7051"
  CORE_PEER_GOSSIP_ORGLEADER: "false"
  CORE_PEER_GOSSIP_USELEADERELECTION: "true"
  # TLS
  CORE_PEER_TLS_ENABLED: "true"
  CORE_PEER_TLS_CERT_FILE: "/etc/hyperledger/fabric-peer/tls/tls.crt"
  CORE_PEER_TLS_KEY_FILE: "/etc/hyperledger/fabric-peer/tls/tls.key"
  CORE_PEER_TLS_ROOTCERT_FILE: "/etc/hyperledger/fabric-peer/msp/tlsca/tlsca-cert.pem"
  CORE_PEER_TLS_CLIENTAUTHREQUIRED: "false"
  ORDERER_TLS_ROOTCERT_FILE: "/etc/hyperledger/fabric-peer/orderer-tlsca-cert.pem"
  CORE_PEER_TLS_CLIENTROOTCAS_FILES: "/etc/hyperledger/fabric-peer/client-root-tlscas/tlsca.${ORG}-cert.pem"
  CORE_PEER_TLS_CLIENTCERT_FILE: "/etc/hyperledger/fabric-peer/tls/tls.crt"
  CORE_PEER_TLS_CLIENTKEY_FILE: "/etc/hyperledger/fabric-peer/tls/tls.key"
  # Docker
  CORE_PEER_NETWORKID: ${ORG}-fabnet
  CORE_VM_ENDPOINT: unix:///host/var/run/docker.sock
  CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE: "bridge"
  # CouchDB
  CORE_LEDGER_STATE_STATEDATABASE: CouchDB
  CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS: 0.0.0.0:5984
  CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME: couchdb
  CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD: couchdb
  # Logging
  CORE_LOGGING_PEER: "info"
  CORE_LOGGING_CAUTHDSL: "info"
  CORE_LOGGING_GOSSIP: "info"
  CORE_LOGGING_LEDGER: "info"
  CORE_LOGGING_MSP: "info"
  CORE_LOGGING_POLICIES: "debug"
  CORE_LOGGING_GRPC: "info"
  GODEBUG: "netdns=go"
---
apiVersion: v1
kind: Service
metadata:
  name: ${PEER}
  namespace: ${ORG}
spec:
  selector:
    app: ${PEER}
  ports:
    - name: request
      port: 7051
      targetPort: 7051
    - name: event
      port: 7053
      targetPort: 7053
  type: LoadBalancer

谁能帮帮我。预先感谢

docker kubernetes hyperledger-fabric hyperledger hyperledger-chaincode
1个回答
0
投票

我建议最好看看 Fabric-samples 中的 K8S 测试网络部署 (https://github.com/hyperledger/fabric-samples/tree/main/test-network-k8s)

请注意,对等方创建链码的经典方法是通过 docker 守护进程创建一个新的 docker 容器。这确实不太适合 K8S,因此强烈推荐使用 fabric-builder-k8s 构建器。

© www.soinside.com 2019 - 2024. All rights reserved.