node.js - 如何使用 kubernetes 集群配置超级账本节点 sdk?
问题描述
我能够使用 cli 配置超级账本结构和 kubernetes。但现在我想用 kubernetes 配置超级账本结构节点 sdk。我已经创建了文件,但无法通过节点 sdk 休息端点连接它。
我的超级账本服务:
[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]
解决方案
我给了错误的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
推荐阅读
- python - 我正在尝试获得一个新的硬件来响应。给出的说明很少。我需要一些帮助才能让我的代码正常工作
- exception - 如何处理 StreamSubscription 中 onData 回调的异常?
- wordpress - WP 或函数添加额外的 br 标签
- apache-nifi - 如何在 Nifi 中将属性设置为空白字符串
- javascript - Laravel - 收藏/取消收藏按钮
- android - 如何存储远程配置的默认数组?
- php - '$wpdb->get_results' 帖子显示在单独的 ccs 表中 - 需要一个表
- c# - PHP 与 C#/.NET 之间的 TripleDES 加密
- python - 如何从字典中接收裸字符串,末尾没有双引号或括号或括号?
- python - 删除嵌套列表中字符串值中的撇号