zoukankan      html  css  js  c++  java
  • kubernetes 设备插件

    kubernetes 官网链接:

    https://v1-18.docs.kubernetes.io/zh/docs/concepts/extend-kubernetes/compute-storage-net/device-plugins/

    项目参考:

    https://github.com/NVIDIA/k8s-device-plugin.git

    源码分析链接:

    https://blog.csdn.net/weixin_42663840/article/details/81231013

    设备插件

    FEATURE STATE: Kubernetes v1.10 [beta]

    Kubernetes 提供了一个设备插件框架,你可以用来将系统硬件资源发布到 Kubelet

    供应商可以实现设备插件,由你手动部署或作为 DaemonSet 来部署,而不必定制 Kubernetes 本身的代码。目标设备包括 GPU、高性能 NIC、FPGA、InfiniBand 适配器以及其他类似的、可能需要特定于供应商的初始化和设置的计算资源。

    注册设备插件 

    kubelet 提供了一个 Registration 的 gRPC 服务:

    service Registration {
    	rpc Register(RegisterRequest) returns (Empty) {}
    }
    

    设备插件可以通过此 gRPC 服务在 kubelet 进行注册。在注册期间,设备插件需要发送下面几样内容:

    • 设备插件的 Unix 套接字。
    • 设备插件的 API 版本。
    • ResourceName 是需要公布的。这里 ResourceName 需要遵循 扩展资源命名方案, 类似于 vendor-domain/resourcetype。(比如 NVIDIA GPU 就被公布为 nvidia.com/gpu。)

    成功注册后,设备插件就向 kubelet 发送他所管理的设备列表,然后 kubelet 负责将这些资源发布到 API 服务器,作为 kubelet 节点状态更新的一部分。

    比如,设备插件在 kubelet 中注册了 hardware-vendor.example/foo 并报告了节点上的两个运行状况良好的设备后,节点状态将更新以通告该节点已安装2个 Foo 设备并且是可用的。

    然后用户需要请求其他类型的资源的时候,就可以在 Container 规范请求这类设备,但是有以下的限制:

    • 扩展资源仅可作为整数资源使用,并且不能被过量使用
    • 设备不能在容器之间共享

    接口:(需要自己去实现)

    // DevicePluginServer is the server API for DevicePlugin service.
    type DevicePluginServer interface {
        // GetDevicePluginOptions returns options to be communicated with Device
        // Manager
        GetDevicePluginOptions(context.Context, *Empty) (*DevicePluginOptions, error)
        // ListAndWatch returns a stream of List of Devices
        // Whenever a Device state change or a Device disappears, ListAndWatch
        // returns the new list
        ListAndWatch(*Empty, DevicePlugin_ListAndWatchServer) error
        // GetPreferredAllocation returns a preferred set of devices to allocate
        // from a list of available ones. The resulting preferred allocation is not
        // guaranteed to be the allocation ultimately performed by the
        // devicemanager. It is only designed to help the devicemanager make a more
        // informed allocation decision when possible.
        GetPreferredAllocation(context.Context, *PreferredAllocationRequest) (*PreferredAllocationResponse, error)
        // Allocate is called during container creation so that the Device
        // Plugin can run device specific operations and instruct Kubelet
        // of the steps to make the Device available in the container
        Allocate(context.Context, *AllocateRequest) (*AllocateResponse, error)
        // PreStartContainer is called, if indicated by Device Plugin during registeration phase,
        // before each container start. Device plugin can run device specific operations
        // such as resetting the device before making devices available to the container
        PreStartContainer(context.Context, *PreStartContainerRequest) (*PreStartContainerResponse, error)
    }
  • 相关阅读:
    理解vue数据驱动
    深入理解vue的watch
    Vue如何用虚拟dom进行渲染view的
    小程序开发-自定义组件的扩展
    让微信小程序页面之间的通信不在变得困难
    借鉴redux,实现一个react状态管理方案
    Vue的computed计算属性是如何实现的
    读redux有感: redux原来是这样操作的。
    web前端面试题记录
    前端知识理解的笔记
  • 原文地址:https://www.cnblogs.com/wangjq19920210/p/15352286.html
Copyright © 2011-2022 走看看