In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to access the IPFS service through python api in Kubernetes. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
IPFS is a distributed globally consistent (see HT and distributed consistent) file system, which combines the advantages of BT, P2P, DHT and so on. In the previous post, I introduced how to deploy IPFS to a Kubernetes cluster and how to expose IPFS services through portforward. At present, IPFS already provides python api to access IPFS services in the cluster.
Basic service preparation
Install IPFS on the Kubernetes cluster through Helm.
The services deployed by IPFS in Kubernetes are open.
Python access to the IPFS service.
IPFS's Python API reference manual.
Install the ipfsapi library pip install ipfsapi access IPFS service # reference ipfsapiimport ipfsapi# to connect to the IPFS management service # if it is running outside the cluster but on the same host as the cluster. # api is the returned client object, and you can use help (api) to view its API. # api = ipfsapi.connect ('127.0.0.1 domains, 5001) # if you are running on the pod of the cluster, use the internal domain name to access the service. # I run it on Jupyter in Kubernetes and the connection is successful. Api = ipfsapi.connect ('ipfs2-ipfs.ipfs2', 5001) # gets the list of peers. # api.swarm_peers () returns a Dict object, and Key is a Peers,value and a list. PeerList = api.swarm_peers () ["Peers"] # shows the total number of Peers, which can change from time to time depending on the network. Len (PeerList) # displays a list of all Peer. Print (PeerList)
Display information about some Peers:
For i in range (3): print (PeerList [I])
The output is as follows:
{'Addr':' / ip4/1.24.210.4/tcp/4001', 'Peer':' QmZgbW9VNA4EJoxuReUmXZNszHqurheeqNQvZ671kdbYLg', 'Latency':', 'Muxer':', 'Streams': None} {' Addr':'/ ip4/100.34.210.63/tcp/39733', 'Peer':' QmPRa5sovWPGhSDuEGU2cgfws5ra91bD89xTWmArJxickp', 'Latency':', 'Muxer':'' 'Streams': None} {' Addr':'/ ip4/100.38.242.117/tcp/10238', 'Peer':' QmXdgmKZYNmybYY33J7UFTuqFdvndEbWY2PdDcHuteqvyj', 'Latency':', 'Muxer':', 'Streams': None}
You can view a variety of information supported by IPFS in the above way, including adding files, downloading files, and so on.
After debugging is completed, you can write a script and further schedule execution in a regular task.
The above is how to access the IPFS service through python api in Kubernetes. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.