繁体   English   中英

如何使用kubernetes集群配置超级账本节点SDK?

[英]how to configure hyperledger node sdk with kubernetes cluster?

我能够使用CLI配置Hyperledger Fabric和kubernetes。 但是现在我想用kubernetes配置超级账本结构节点sdk。 我已经创建了文件,但是无法通过节点sdk rest端点将其连接。

我的超级账本服务:

[ec2-user@ip-172-31-21-223 ~]$ kubectl get services --namespace=fabrick8s
NAME                   TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)                           AGE
ca0-org1               NodePort   10.110.184.19   <none>        30101:30101/TCP,30102:30102/TCP   26h
orderer0-orgorderer1   NodePort   10.99.12.255    <none>        32000:32000/TCP                   46h
peer0-org1             NodePort   10.101.50.225   <none>        30001:30001/TCP,30002:30002/TCP   3h5m

我已将cluser ip添加到节点网络配置文件中,但无法连接。 得到以下错误:

[2019-09-12 09:12:08.169] [INFO] SampleWebApp - ****************** SERVER STARTED ************************
[2019-09-12 09:12:08.175] [INFO] SampleWebApp - ***************  http://localhost:4000  ******************
(node:2199) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead
[2019-09-12 09:12:16.427] [DEBUG] SampleWebApp -  ------>>>>>> new request for /users
[2019-09-12 09:12:16.428] [DEBUG] SampleWebApp - End point : /users
[2019-09-12 09:12:16.428] [DEBUG] SampleWebApp - User name : test
[2019-09-12 09:12:16.428] [DEBUG] SampleWebApp - Org name  : Org1
[2019-09-12 09:12:16.432] [DEBUG] Helper - getClientForOrg - ****** START Org1 undefined
[2019-09-12 09:12:16.439] [DEBUG] Helper - [NetworkConfig101.js]: constructor, network_config: {"name":"HlfV1","x-type":"hlfv1","description":"Hyperledger Node SDK","version":"1.0","channels":{"mychannel":{"orderers":["orderer0-orgorderer1"],"peers":{"peer0-org1":{"endorsingPeer":true,"chaincodeQuery":true,"ledgerQuery":true,"eventSource":true}},"chaincodes":["mycc:v0"]}},"organizations":{"Org1":{"mspid":"Org1MSP","peers":["peer0-org1"],"certificateAuthorities":["ca0-org1"],"adminPrivateKey":{"path":"/var/lib/nfs-share/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/keystore/a6b8f684b67417335a33972cf115efe2222fdf07de1187cfab36c4873e7591af_sk"},"signedCert":{"path":"/var/lib/nfs-share/crypto-config/peerOrganizations/org1/users/Admin@org1/msp/signcerts/Admin@org1-cert.pem"}}},"orderers":{"orderer0-orgorderer1":{"url":"grpcs://localhost:32000","grpcOptions":{"ssl-target-name-override":"orderer0-orgorderer1"},"tlsCACerts":{"path":"/var/lib/nfs-share/crypto-config/ordererOrganizations/orgorderer1/orderers/orderer0.orgorderer1/tls/ca.crt"}}},"peers":{"peer0-org1":{"url":"grpcs://localhost:30001","grpcOptions":{"ssl-target-name-override":"peer0-org1"},"tlsCACerts":{"path":"/var/lib/nfs-share/crypto-config/peerOrganizations/org1/peers/peer0.org1/tls/ca.crt"}}},"certificateAuthorities":{"ca0-org1":{"url":"https://localhost:30101","httpOptions":{"verify":false},"tlsCACerts":{"path":"/var/lib/nfs-share/crypto-config/peerOrganizations/org1/ca/ca.org1-cert.pem"},"registrar":[{"enrollId":"admin","enrollSecret":"adminpw"}],"caName":"ca0-org1"}}}
[2019-09-12 09:12:16.439] [DEBUG] Helper - [NetworkConfig101.js]: constructor, network_config: {"name":"HLF-Framework-Org1","x-type":"hlfv1","description":"HLF-Framework - client definition for Org1","version":"1.0","client":{"organization":"Org1","credentialStore":{"path":"./fabric-client-kv-Org1","cryptoStore":{"path":"/tmp/fabric-client-kv-Org1"},"wallet":"wallet-name"}}}
[2019-09-12 09:12:16.440] [DEBUG] Helper - [NetworkConfig101.js]: mergeSettings - additions start
[2019-09-12 09:12:16.440] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-09-12 09:12:16.440] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-09-12 09:12:16.441] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca0-org1
[2019-09-12 09:12:16.444] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-09-12 09:12:16.626] [DEBUG] Helper - [crypto_ecdsa_aes]: Hash algorithm: SHA2, hash output size: 256
[2019-09-12 09:12:16.696] [DEBUG] Helper - [crypto_ecdsa_aes]: importKey - start
[2019-09-12 09:12:16.698] [DEBUG] Helper - [crypto_ecdsa_aes]: importKey - have the key [Circular]
[2019-09-12 09:12:16.699] [DEBUG] Helper - [crypto_ecdsa_aes]: importKey - start
[2019-09-12 09:12:16.701] [DEBUG] Helper - [crypto_ecdsa_aes]: importKey - have the key [Circular]
[2019-09-12 09:12:16.701] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-09-12 09:12:16.702] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-09-12 09:12:16.702] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca0-org1
[2019-09-12 09:12:16.702] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-09-12 09:12:16.703] [DEBUG] Helper - [FileKeyValueStore.js]: constructor { options:
   { path: '/home/ec2-user/kube-node-sdk/fabric-client-kv-Org1',
     wallet: 'wallet-name',
     cryptoStore: { path: '/tmp/fabric-client-kv-Org1' } } }
[2019-09-12 09:12:16.708] [DEBUG] Helper - [crypto_ecdsa_aes]: Hash algorithm: SHA2, hash output size: 256
[2019-09-12 09:12:16.709] [DEBUG] Helper - [utils.CryptoKeyStore]: CryptoKeyStore, constructor - start
[2019-09-12 09:12:16.709] [DEBUG] Helper - [utils.CryptoKeyStore]: constructor, no super class specified, using config: fabric-client/lib/impl/FileKeyValueStore.js
[2019-09-12 09:12:16.709] [DEBUG] Helper - getClientForOrg - ****** END Org1 undefined


[2019-09-12 09:12:16.709] [DEBUG] Helper - Successfully initialized the credential stores
[2019-09-12 09:12:16.710] [DEBUG] Helper - [FileKeyValueStore.js]: getValue { key: 'test' }
[2019-09-12 09:12:16.716] [INFO] Helper - User test was not enrolled, so we will need an admin user object to register
[2019-09-12 09:12:16.717] [DEBUG] Helper - [FileKeyValueStore.js]: getValue { key: 'admin' }
[2019-09-12 09:12:16.717] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-09-12 09:12:16.717] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-09-12 09:12:16.717] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca0-org1
[2019-09-12 09:12:16.718] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-09-12 09:12:16.718] [DEBUG] Helper - [NetworkConfig101.js]: getOrganization - name Org1
[2019-09-12 09:12:16.718] [DEBUG] Helper - [Organization.js]: Organization.const
[2019-09-12 09:12:16.718] [DEBUG] Helper - [NetworkConfig101.js]: getCertificateAuthority - name ca0-org1
[2019-09-12 09:12:16.718] [DEBUG] Helper - [CertificateAuthority.js]: CertificateAuthority.const
[2019-09-12 09:12:16.732] [DEBUG] Helper - [FabricCAClient.js]: Successfully constructed Fabric CA client from options - {"caname":"ca0-org1","protocol":"https","hostname":"localhost","port":30101,"tlsOptions":{"trustedRoots":["-----BEGIN CERTIFICATE-----\nMIICIjCCAcigAwIBAgIRANPRopfisvYPfsGHY1tke+MwCgYIKoZIzj0EAwIwWzEL\nMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBG\ncmFuY2lzY28xDTALBgNVBAoTBG9yZzExEDAOBgNVBAMTB2NhLm9yZzEwHhcNMTkw\nNzA5MjMzMDAwWhcNMjkwNzA2MjMzMDAwWjBbMQswCQYDVQQGEwJVUzETMBEGA1UE\nCBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzENMAsGA1UEChME\nb3JnMTEQMA4GA1UEAxMHY2Eub3JnMTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA\nBMQsUoC5j79WG1YA0ZgfjnxYkv3TQlFUujWvSpcSG3911uxWBBG8tBxalcY6XubW\ndEk+QNReLYz5XWVclzmJZZujbTBrMA4GA1UdDwEB/wQEAwIBpjAdBgNVHSUEFjAU\nBggrBgEFBQcDAgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB/zApBgNVHQ4EIgQg\nxbTg5ty+qp3Jny2uw/eHWhfPT3w0LrE/MeG74D9Vd2YwCgYIKoZIzj0EAwIDSAAw\nRQIhANJxDvpI0R59X3DLoegKxwpFKKwnA3yhJZCtsoQ4TvPAAiBOKIf3AMpBrfFl\nx9DjYULlHqYcCMCG9jROisk8e0y2uA==\n-----END CERTIFICATE-----\n"],"verify":false}}
[2019-09-12 09:12:16.732] [DEBUG] Helper - [FabricCAClientService.js]: Successfully constructed Fabric CA service client: endpoint - {"protocol":"https","hostname":"localhost","port":30101}
[2019-09-12 09:12:16.785] [DEBUG] Helper - [utils.CryptoKeyStore]: This class requires a CryptoKeyStore to save keys, using the store: {"opts":{"path":"/tmp/fabric-client-kv-Org1"}}
[2019-09-12 09:12:16.785] [DEBUG] Helper - [FileKeyValueStore.js]: constructor { options: { path: '/tmp/fabric-client-kv-Org1' } }
[2019-09-12 09:12:16.786] [DEBUG] Helper - [utils.CryptoKeyStore]: _getKeyStore returning ks
[2019-09-12 09:12:16.786] [DEBUG] Helper - [crypto_ecdsa_aes]: generateKey, store.setValue
[2019-09-12 09:12:16.786] [DEBUG] Helper - [ecdsa/key.js]: ECDSA curve param X: c93658d3386293eed8cbbd07d9124d7e0bb354ceb1bbbba80099dc9a942b9ed3
[2019-09-12 09:12:16.787] [DEBUG] Helper - [ecdsa/key.js]: ECDSA curve param Y: 3444c31a9342c0bedae13aff1e5d43ed610ca641a597355e5af25c973708c4ef
[2019-09-12 09:12:16.791] [DEBUG] Helper - [FileKeyValueStore.js]: setValue { key:
   '4ef322eb862cc68caf4341999813959a931baa492a0dcd227f73bf8afa803301-priv' }
[2019-09-12 09:12:16.843] [ERROR] Helper - Failed to get registered user: test with error: Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:30101]
[2019-09-12 09:12:16.843] [DEBUG] SampleWebApp - -- returned from registering the username test for organization Org1
[2019-09-12 09:12:16.843] [DEBUG] SampleWebApp - Failed to register the username test for organization Org1 with::failed Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:30101]

添加新的Organization Org1后,请检查是否用新生成的密钥替换了/keystore/key 如果不是,则需要相应组织密钥的更新路径。

另一件事是检查包含CA服务的yaml文件,是否启用了TLS参数?

environment:
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_TLS_CERTFILE=<location to certificate file>
- FABRIC_CA_SERVER_TLS_KEYFILE=<location to key file>

当NodeSDK应用程序在本地虚拟环境中使用光纤网络时,对等地址被视为“本地主机”,则虚拟环境中的端口地址也必须是唯一的。 请检查文档以了解更多信息。

我给错了targetPort ..因为CA目标端口是7054。解决了我的问题:)

apiVersion: v1
kind: Service
metadata:
   namespace: fabrick8s
   name: ca0-org1
spec:
 selector:
   name: ca0-org1
 type: NodePort
 ports:
   - name: grpc
     protocol: TCP
     port: 30101
     targetPort: 7054
     nodePort: 30101

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM