内容来源于官方 Longhorn 1.1.2 英文技术手册。

系列

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

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

    并连接到端点 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/longhorn/longhorn-tests/tree/master/manager/integration/tests
公众号:黑客下午茶

Longhorn 云原生容器分布式存储 - Python Client的更多相关文章

  1. Longhorn 云原生容器分布式存储 - 故障排除指南

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生容器分布式存储 - 设计架构和概念 Longhorn 云原生容器分布式存储 - ...

  2. Longhorn 云原生容器分布式存储 - Air Gap 安装

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生容器分布式存储 - 设计架构和概念 Longhorn 云原生容器分布式存储 - ...

  3. Longhorn,企业级云原生容器分布式存储 - 定制默认设置

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生容器分布式存储 - 设计架构和概念 Longhorn 云原生容器分布式存储 - ...

  4. Longhorn,企业级云原生容器分布式存储 - 备份与恢复

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  5. Longhorn,企业级云原生容器分布式存储 - K8S 资源配置示例

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  6. Longhorn,企业级云原生容器分布式存储 - 监控(Prometheus+AlertManager+Grafana)

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  7. Longhorn,企业级云原生容器分布式存储 - 高可用

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  8. Longhorn,企业级云原生容器分布式存储 - 支持 ReadWriteMany (RWX) 工作负载(实验性功能)

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  9. Longhorn 企业级云原生容器存储解决方案-部署篇

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 云原生分布式块存储解决方案设计架构和概念 安装 Longhorn 可以通过多种方式安装 ...

随机推荐

  1. 动静态web项目(三)

    在Eclipse中将web项目分为了Dynamic Web Project和Static Web Project. 那么这两种有什么区别呢? 其实这里的Dynamic和Static是通过页面来区分的. ...

  2. CentOS7安装桌面环境以及中文语言支持

    CentOS7 操作系统 http://public-yum.oracle.com/oracle-linux-isos.html ================================= 1 ...

  3. 【小工具系列】Python + OpenCV 图片序列转换成视频

    图片序列转换成视频 最近一直在找一个工具,能够将一堆图片转化成视频.网上找了一些小软件,还有 win10 的照片自带的视频制作功能,都不是很满意. 又不想下载那些专业的视频剪辑软件大材小用. 然后找到 ...

  4. phpmyadmin scripts/setup.php 反序列化漏洞(WooYun-2016-199433)

    phpmyadmin 2.x版本 POST /scripts/setup.php HTTP/1.1 Host: 192.168.49.2:8080 Accept-Encoding: gzip, def ...

  5. xxe 回显与无回显

    转载学习于红日安全 一.有回显 (1)直接将外部实体引用的URI设置为敏感目录 <!DOCTYPE foo [<!ELEMENT foo ANY > <!ENTITY  xxe ...

  6. String,String Builder,String Buffer-源码

    目录 String 源码分析 常用的API isEmpty() length() charAt() substring() equals() equals()与"==" inter ...

  7. 等Excel工作簿关闭后自动加密压缩备份2019年10月9日.ahk

    ;; 等Excel工作簿关闭后自动加密压缩备份2019年10月9日.ahk;; 腾讯QQ号 595076941; 作者:徐晓亮(weiyunwps618); 写作日期:2019年5月15日; 版本号: ...

  8. SPOJ ABCDEF题解

    题面 源 OJ 未 AC(卡 \(map\) ,不想写 \(hash\) ). 看到 \(n \leq 100\) ,显然 \(O(n^6)\) 会挂掉,所以要优化. 考虑到原式可化为 \(a \ti ...

  9. 6.算法竞赛中的常用JAVA API :Math类(转载)

    6.算法竞赛中的常用JAVA API :Math类 求最值 最小值 Math.min(int a, int b) Math.min(float a, float b) Math.min(double ...

  10. Spring源码浅析之bean实例的创建过程(一)

    在之前的文章内容中,简单介绍了bean定义的加载过程,下面这篇的主要内容就是bean实例的创建过程. bean实例的创建方式 ApplicationContext context = new Clas ...