提供者

扩展虚拟立方体界面

虚拟立方体提供可插拔的提供者界面,开发人员可以实现它以定义典型立方体的操作。

在无需管理虚拟机基础设施的情况下,这支持按需和几乎即时的容器计算,由 Kubernetes 协调。

每个提供者可能都有自己的配置文件和必要的环境变量。

提供者接口

虚拟立方体提供者必须提供以下功能,才能被认为是完全兼容的集成

  1. 提供支持 Kubernetes 背景下 Pod、容器和支持资源的生命周期管理所必需的后端管道。
  2. 符合虚拟立方体提供的当前 API。
  3. 限制对Kubernetes API 服务器的所有访问,并提供一个明确的回调机制来检索数据,例如SecretConfigMap

当前提供者

虚拟立方体当前拥有各种提供者

海军部多集群调度程序文档GoDoc
阿里云弹性容器实例 (ECI)文档GoDoc
AWS Fargate文档GoDoc
Azure Batch文档GoDoc
Azure 容器实例 (ACI)文档GoDoc
Elotl Kip文档GoDoc
Kubernetes 容器运行时接口 (CRI)文档GoDoc
华为云容器实例 (CCI)文档GoDoc
HashiCorp Nomad文档GoDoc
InterLink文档GoDoc
Liqo文档GoDoc
OpenStack Zun文档GoDoc
腾讯游戏 Tensile Kube文档GoDoc
StackPath 边缘计算文档GoDoc

添加新提供者

要添加新的虚拟立方体提供者,请为你的提供者创建一个新目录。

在创建的目录中,使用PodLifecycleHandlerGo中实现界面。

有关虚拟立方体PodLifecycleHandler界面的示例实现,请参阅虚拟立方体 CRI 提供者,尤其是cri.go

每个虚拟 Kubelet 提供程序都可以使用自己的配置文件和环境变量进行配置。

您可以在下面看到所需方法列表,以及每种方法的相关说明

// PodLifecycleHandler defines the interface used by the PodController to react
// to new and changed pods scheduled to the node that is being managed.
//
// Errors produced by these methods should implement an interface from
// github.com/virtual-kubelet/virtual-kubelet/errdefs package in order for the
// core logic to be able to understand the type of failure.
type PodLifecycleHandler interface {
    // CreatePod takes a Kubernetes Pod and deploys it within the provider.
    CreatePod(ctx context.Context, pod *corev1.Pod) error

    // UpdatePod takes a Kubernetes Pod and updates it within the provider.
    UpdatePod(ctx context.Context, pod *corev1.Pod) error

    // DeletePod takes a Kubernetes Pod and deletes it from the provider.
    DeletePod(ctx context.Context, pod *corev1.Pod) error

    // GetPod retrieves a pod by name from the provider (can be cached).
    // The Pod returned is expected to be immutable, and may be accessed
    // concurrently outside of the calling goroutine. Therefore it is recommended
    // to return a version after DeepCopy.
    GetPod(ctx context.Context, namespace, name string) (*corev1.Pod, error)

    // GetPodStatus retrieves the status of a pod by name from the provider.
    // The PodStatus returned is expected to be immutable, and may be accessed
    // concurrently outside of the calling goroutine. Therefore it is recommended
    // to return a version after DeepCopy.
    GetPodStatus(ctx context.Context, namespace, name string) (*corev1.PodStatus, error)

    // GetPods retrieves a list of all pods running on the provider (can be cached).
    // The Pods returned are expected to be immutable, and may be accessed
    // concurrently outside of the calling goroutine. Therefore it is recommended
    // to return a version after DeepCopy.
    GetPods(context.Context) ([]*corev1.Pod, error)
}

除了 PodLifecycleHandler 之外,还提供了一个可选的 PodMetricsProvider 接口,提供程序可以通过实现该接口来公开 Kubernetes Pod 统计

type PodMetricsProvider interface {
    GetStatsSummary(context.Context) (*stats.Summary, error)
}

要使虚拟 Kubelet 提供程序被视为可行,它必须支持以下功能

  1. 它必须提供在 Kubernetes 上下文中支持 Pod、容器和支持资源生命周期管理所必需的后端管道。
  2. 它必须符合 Virtual Kubelet (参见 上文) 提供的当前 API。
  3. 它无法访问 Kubernetes API 服务器,因此它必须提供明确定义的回调机制,用来获取 机密ConfigMap 等数据。

文档

没有可靠的文档,任何 Virtual Kubelet 提供程序是不完整的。我们强烈建议为其目录中的提供程序提供 README。当前现有实现的 README 可以提供蓝图。

您可能会希望您的提供程序出现在 当前提供程序列表 中。该列表由 provider.yaml 文件生成。为提供程序的显示名称添加一个 name 字段,并将子目录作为 tag 字段。name 字段支持 Markdown,因此请随意使用粗体或超链接。

测试

为了测试您正在开发的提供程序,只需从 Virtual Kubelet 目录的根目录运行 make test



© 2024 Virtual Kubelet 作者

提供者