日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Longhorn云原生容器分布式存儲-PythonClient

Longhorn 云原生容器分布式存儲 - Python Client

作者:為少 2021-09-03 05:00:28

存儲

存儲軟件

云原生

分布式 如果您在本地機器上運行自動化/腳本(automation/scripting)工具,請使用 kubectl port-forward 將 longhorn-frontend service 轉發(fā)到 localhost。

成都創(chuàng)新互聯(lián)于2013年創(chuàng)立,先為眉山等服務建站,眉山等地企業(yè),進行企業(yè)商務咨詢服務。為眉山企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務解決您的所有建站問題。

 [[421320]]

本文轉載自微信公眾號「黑客下午茶」,作者為少。轉載本文請聯(lián)系黑客下午茶公眾號。

目前,您可以使用 Longhorn UI 操作 Longhorn。同時,您可以使用 Python 訪問 Longhorn API,如下所示。

1.獲取 Longhorn API 端點

與 Longhorn 通信的一種方式是通過 longhorn-frontend service。

如果您在安裝 Longhorn 的同一集群中運行自動化/腳本(automation/scripting)工具,請連接到端點 http://longhorn-frontend.longhorn-system/v1

如果您在本地機器上運行自動化/腳本(automation/scripting)工具,請使用 kubectl port-forward 將 longhorn-frontend service 轉發(fā)到 localhost:

  
 
 
  1. kubectl port-forward services/longhorn-frontend 8080:http -n longhorn-system 

并連接到端點 http://localhost:8080/v1

2.使用 Python Client

將 longhorn.py 文件(包含 Python client)導入到以下 Python 腳本中,并從 API 端點創(chuàng)建一個 client:

https://github.com/longhorn/longhorn-tests/blob/master/manager/integration/tests/longhorn.py

  
 
 
  1. import longhorn 
  2.  
  3. # If automation/scripting tool is inside the same cluster in which Longhorn is installed 
  4. longhorn_url = 'http://longhorn-frontend.longhorn-system/v1' 
  5. # If forwarding `longhorn-frontend` service to localhost 
  6. longhorn_url = 'http://localhost:8080/v1' 
  7.  
  8. client = longhorn.Client(url=longhorn_url) 
  9.  
  10. # Volume operations 
  11. # List all volumes 
  12. volumes = client.list_volume() 
  13. # Get volume by NAME/ID 
  14. testvol1 = client.by_id_volume(id="testvol1") 
  15. # Attach TESTVOL1 
  16. testvol1 = testvol1.attach(hostId="worker-1") 
  17. # Detach TESTVOL1 
  18. testvol1.detach() 
  19. # Create a snapshot of TESTVOL1 with NAME 
  20. snapshot1 = testvol1.snapshotCreate(name="snapshot1") 
  21. # Create a backup from a snapshot NAME 
  22. testvol1.snapshotBackup(name=snapshot1.name) 
  23. # Update the number of replicas of TESTVOL1 
  24. testvol1.updateReplicaCount(replicaCount=2) 
  25. # Find more examples in Longhorn integration tests https://github.com/longhorn/longhorn-tests/tree/master/manager/integration/tests 
  26.  
  27. # Node operations 
  28. # List all nodes 
  29. nodes = client.list_node() 
  30. # Get node by NAME/ID 
  31. node1 = client.by_id_node(id="worker-1") 
  32. # Disable scheduling for NODE1 
  33. client.update(node1, allowScheduling=False) 
  34. # Enable scheduling for NODE1 
  35. client.update(node1, allowScheduling=True) 
  36. # Find more examples in Longhorn integration tests https://github.com/longhorn/longhorn-tests/tree/master/manager/integration/tests 
  37.  
  38. # Setting operations 
  39. # List all settings 
  40. settings = client.list_setting() 
  41. # Get setting by NAME/ID 
  42. backupTargetsetting = client.by_id_setting(id="backup-target") 
  43. # Update a setting 
  44. backupTargetsetting = client.update(backupTargetsetting, value="s3://backupbucket@us-east-1/") 
  45. # Find more examples in Longhorn integration tests https://github.com/longhorn/longhorn-tests/tree/master/manager/integration/tests 

 


分享標題:Longhorn云原生容器分布式存儲-PythonClient
URL地址:http://www.5511xx.com/article/coeiijp.html