自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

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

存儲 存儲軟件 云原生 分布式
如果您在本地機(jī)器上運行自動化/腳本(automation/scripting)工具,請使用 kubectl port-forward 將 longhorn-frontend service 轉(zhuǎn)發(fā)到 localhost。

 [[421320]]

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

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

1.獲取 Longhorn API 端點

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

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

如果您在本地機(jī)器上運行自動化/腳本(automation/scripting)工具,請使用 kubectl port-forward 將 longhorn-frontend service 轉(zhuǎn)發(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)導(dǎo)入到以下 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 

 

責(zé)任編輯:武曉燕 來源: 黑客下午茶
相關(guān)推薦

2021-08-29 23:53:32

存儲Air Gap安裝

2021-10-18 23:49:50

云原生分布式存儲

2021-08-26 00:23:14

分布式存儲高可用

2021-08-17 00:24:38

塊存儲云原生分布式

2021-08-24 05:02:34

云原生容器分布式

2022-02-21 10:17:33

Rancher開源云原生

2021-08-25 05:05:26

存儲 備份恢復(fù)

2021-08-26 23:54:46

分布式存儲負(fù)載

2021-08-28 05:04:19

存儲云原生分布式

2021-08-17 12:36:21

Longhorn云原生存儲

2021-08-18 14:33:53

存儲云原生容器

2023-09-14 15:38:55

云原生分布式架構(gòu)

2022-10-10 17:21:50

固態(tài)硬盤分布式云存儲

2017-10-27 08:40:44

分布式存儲剪枝系統(tǒng)

2022-09-15 21:04:20

JuiceFS云原生

2024-08-12 16:20:27

2015-05-12 13:03:54

開源分布式存儲HDFS

2020-09-02 16:39:00

青云QingCloud存儲QingStor

2020-02-20 11:56:38

容器云分布式存儲哪種更好
點贊
收藏

51CTO技術(shù)棧公眾號