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

本文涉及的产品
容器镜像服务 ACR,镜像仓库100个 不限时长
简介: Longhorn 云原生容器分布式存储 - Python Client

目前,您可以使用 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-forwardlonghorn-frontendservice 转发到 localhost


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


  1. 并连接到端点 http://localhost:8080/v1
  2. 使用 Python Client
    将 longhorn.py 文件(包含 Python client)导入到以下 Python 脚本中,并从 API 端点创建一个 client
    https://github.com/longhorn/longhorn-tests/blob/master/manager/integration/tests/longhorn.py


import longhorn
# If automation/scripting tool is inside the same cluster in which Longhorn is installed
longhorn_url = 'http://longhorn-frontend.longhorn-system/v1'
# If forwarding `longhorn-frontend` service to localhost
longhorn_url = 'http://localhost:8080/v1'
client = longhorn.Client(url=longhorn_url)
# Volume operations
# List all volumes
volumes = client.list_volume()
# Get volume by NAME/ID
testvol1 = client.by_id_volume(id="testvol1")
# Attach TESTVOL1
testvol1 = testvol1.attach(hostId="worker-1")
# Detach TESTVOL1
testvol1.detach()
# Create a snapshot of TESTVOL1 with NAME
snapshot1 = testvol1.snapshotCreate(name="snapshot1")
# Create a backup from a snapshot NAME
testvol1.snapshotBackup(name=snapshot1.name)
# Update the number of replicas of TESTVOL1
testvol1.updateReplicaCount(replicaCount=2)
# Find more examples in Longhorn integration tests https://github.com/longhorn/longhorn-tests/tree/master/manager/integration/tests
# Node operations
# List all nodes
nodes = client.list_node()
# Get node by NAME/ID
node1 = client.by_id_node(id="worker-1")
# Disable scheduling for NODE1
client.update(node1, allowScheduling=False)
# Enable scheduling for NODE1
client.update(node1, allowScheduling=True)
# Find more examples in Longhorn integration tests https://github.com/longhorn/longhorn-tests/tree/master/manager/integration/tests
# Setting operations
# List all settings
settings = client.list_setting()
# Get setting by NAME/ID
backupTargetsetting = client.by_id_setting(id="backup-target")
# Update a setting
backupTargetsetting = client.update(backupTargetsetting, value="s3://backupbucket@us-east-1/")
# Find more examples in Longhorn integration tests https://github.com/lo


相关文章
|
6月前
|
Cloud Native 关系型数据库 分布式数据库
登顶TPC-C|云原生数据库PolarDB技术揭秘:Limitless集群和分布式扩展篇
阿里云PolarDB云原生数据库在TPC-C基准测试中以20.55亿tpmC的成绩刷新世界纪录,展现卓越性能与性价比。其轻量版满足国产化需求,兼具高性能与低成本,适用于多种场景,推动数据库技术革新与发展。
|
2月前
|
Cloud Native 中间件 调度
云原生信息提取系统:容器化流程与CI/CD集成实践
本文介绍如何通过工程化手段解决数据提取任务中的稳定性与部署难题。结合 Scrapy、Docker、代理中间件与 CI/CD 工具,构建可自动运行、持续迭代的云原生信息提取系统,实现结构化数据采集与标准化交付。
云原生信息提取系统:容器化流程与CI/CD集成实践
|
5月前
|
Cloud Native 关系型数据库 分布式数据库
登顶TPC-C|云原生数据库PolarDB技术揭秘:Limitless集群和分布式扩展篇
云原生数据库PolarDB技术揭秘:Limitless集群和分布式扩展篇
|
4月前
|
数据采集 存储 NoSQL
分布式爬虫去重:Python + Redis实现高效URL去重
分布式爬虫去重:Python + Redis实现高效URL去重
|
4月前
|
Kubernetes Cloud Native 区块链
Arista cEOS 4.30.10M - 针对云原生环境设计的容器化网络操作系统
Arista cEOS 4.30.10M - 针对云原生环境设计的容器化网络操作系统
136 0
|
8月前
|
分布式计算 DataWorks 大数据
分布式Python计算服务MaxFrame测评
一文带你入门分布式Python计算服务MaxFrame
157 23
分布式Python计算服务MaxFrame测评
|
8月前
|
分布式计算 DataWorks 数据处理
产品测评 | 上手分布式Python计算服务MaxFrame产品最佳实践
MaxFrame是阿里云自研的分布式计算框架,专为大数据处理设计,提供高效便捷的Python开发体验。其主要功能包括Python编程接口、直接利用MaxCompute资源、与MaxCompute Notebook集成及镜像管理功能。本文基于MaxFrame最佳实践,详细介绍了在DataWorks中使用MaxFrame创建数据源、PyODPS节点和MaxFrame会话的过程,并展示了如何通过MaxFrame实现分布式Pandas处理和大语言模型数据处理。测评反馈指出,虽然MaxFrame具备强大的数据处理能力,但在文档细节和新手友好性方面仍有改进空间。
|
8月前
|
SQL 分布式计算 DataWorks
MaxCompute MaxFrame评测 | 分布式Python计算服务MaxFrame(完整操作版)
在当今数字化迅猛发展的时代,数据信息的保存与分析对企业决策至关重要。MaxCompute MaxFrame是阿里云自研的分布式计算框架,支持Python编程接口、兼容Pandas接口并自动进行分布式计算。通过MaxCompute的海量计算资源,企业可以进行大规模数据处理、可视化数据分析及科学计算等任务。本文将详细介绍如何开通MaxCompute和DataWorks服务,并使用MaxFrame进行数据操作。包括创建项目、绑定数据源、编写PyODPS 3节点代码以及执行SQL查询等内容。最后,针对使用过程中遇到的问题提出反馈建议,帮助用户更好地理解和使用MaxFrame。
|
7月前
|
Python
云产品评测|分布式Python计算服务MaxFrame获奖名单公布!
云产品评测|分布式Python计算服务MaxFrame获奖名单公布!
139 0
|
8月前
|
SQL 分布式计算 数据处理
云产品评测|分布式Python计算服务MaxFrame | 在本地环境中使用MaxFrame + 基于MaxFrame实现大语言模型数据处理
本文基于官方文档,介绍了由浅入深的两个部分实操测试,包括在本地环境中使用MaxFrame & 基于MaxFrame实现大语言模型数据处理,对步骤有详细说明。体验下来对MaxCompute的感受是很不错的,值得尝试并使用!
190 1

推荐镜像

更多