# KServe

**KServe** 是一个面向 [Kubernetes](https://www.edgepedia.org/zh/kubernetes) 的开源模型服务平台，通过 Kubernetes 自定义资源（扩展 API 的用户定义 Kubernetes 对象）来部署、扩缩和路由机器学习推理工作负载，主要依托 `InferenceService` 自定义资源定义（CRD）。它最初名为 KFServing，由 Google、IBM、Bloomberg、NVIDIA 和 Seldon 于 2019 年合作开发并于 2019 年初开源发布，2021 年 9 月更名为 KServe，代码仓库迁至 Kubeflow Serving 工作组下属的独立 GitHub 组织。<sup>[1](https://blog.kubeflow.org/release/official/2021/09/27/kfserving-transition.html)</sup> 该项目目前正在[云原生计算基金会](https://www.edgepedia.org/zh/cloud-native-computing-foundation)（CNCF）中孵化。<sup>[2](https://www.spheron.network/blog/kserve-vs-seldon-core-vs-bentoml-kubernetes-ml-serving-guide/)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 2019 年由 Google、IBM、Bloomberg、NVIDIA 和 Seldon 开发；2019 年初以 KFServing 之名开源<sup>[1](https://blog.kubeflow.org/release/official/2021/09/27/kfserving-transition.html)</sup> |
| 更名 | 2021 年 9 月更名为 KServe；仓库转移至独立 GitHub 组织<sup>[1](https://blog.kubeflow.org/release/official/2021/09/27/kfserving-transition.html)</sup> |
| 核心资源 | `InferenceService`（v1beta1），是部署模型的主要抽象，内置自动扩缩、版本管理和流量管理<sup>[3](https://kserve.github.io/website/docs/concepts/resources)</sup> |
| 部署模式 | 标准模式（RawDeployment）和 Knative 模式（无服务器）；Knative 模式提供缩容至零<sup>[4](https://kserve.github.io/website/docs/concepts/architecture/control-plane)</sup> |
| 自动扩缩 | 无服务器模式下使用 Knative Pod 自动扩缩器（KPA）；标准模式下使用 HPA，并可选配 KEDA<sup>[4](https://kserve.github.io/website/docs/concepts/architecture/control-plane)</sup> |
| 多模型服务 | ModelMesh Serving 在每个运行时 Pod 中装载多个模型，内置 Triton、MLServer 和 OpenVINO Model Server 运行时<sup>[5](https://github.com/kserve/modelmesh-serving/blob/main/docs/README.md)</sup> |
| CNCF 状态 | 孵化中<sup>[2](https://www.spheron.network/blog/kserve-vs-seldon-core-vs-bentoml-kubernetes-ml-serving-guide/)</sup> |

## 历史

KFServing 的目标是提供一个 Kubernetes 自定义资源，用于跨框架部署机器学习模型，同时提供标准化的推理协议、在 CPU 和 GPU 上均可缩容至零的无服务器推理，以及覆盖预测、预处理与后处理、可解释性和监控的生产级方案。<sup>[1](https://blog.kubeflow.org/release/official/2021/09/27/kfserving-transition.html)</sup> 随着采用范围扩大，项目范围也随之扩展，需要独立的文档站点和 GitHub 组织。2021 年 9 月，KFServing 仓库转移至独立的 KServe 组织，项目更名，团队计划于当年晚些时候从 Kubeflow 毕业。KServe 0.7 是 Kubeflow 项目之外的首个版本，KFServing 0.5.x 和 0.6.x 版本在其发布后继续获得六个月支持。<sup>[1](https://blog.kubeflow.org/release/official/2021/09/27/kfserving-transition.html)</sup>

## 自定义资源

KServe 通过自定义资源扩展 Kubernetes，以声明式方式管理模型服务，由 KServe 控制平面统一管理。<sup>[3](https://kserve.github.io/website/docs/concepts/resources)</sup> 核心资源包括：

- **InferenceService**：部署和管理模型服务工作负载的主要资源，具备自动扩缩、版本管理和流量管理能力。<sup>[3](https://kserve.github.io/website/docs/concepts/resources)</sup>
- **InferenceGraph**：定义和管理推理流水线与模型链的 CRD，负责模型间的请求路由和数据流。<sup>[3](https://kserve.github.io/website/docs/concepts/resources)</sup>
- **ServingRuntime 和 ClusterServingRuntime**：分别在命名空间范围和集群范围定义服务模型的运行环境。<sup>[3](https://kserve.github.io/website/docs/concepts/resources)</sup>
- **StorageContainer 和 ClusterStorageContainer**：配置模型存储后端和访问方式。<sup>[3](https://kserve.github.io/website/docs/concepts/resources)</sup>
- **LocalModel 资源**：LocalModelCache、LocalModelNamespaceCache、LocalModelNode 和 LocalModelNodeGroup，在集群、命名空间和节点级别管理本地模型缓存。<sup>[3](https://kserve.github.io/website/docs/concepts/resources)</sup>

InferenceService 的 predictor 指定模型格式、模型存储位置和可选配置，并暴露一个稳定端点，在 spec 更新时可在模型版本之间无缝切换。<sup>[5](https://github.com/kserve/modelmesh-serving/blob/main/docs/README.md)</sup>

## 控制平面与部署模式

KServe 控制平面管理推理服务的生命周期，与 Kubernetes API 协调，处理资源编排，并提供自动扩缩能力。其核心组件是 KServe Controller Manager，负责调谐 InferenceService 资源，创建底层 Deployment、Service 和网络配置，并设置自动扩缩。其他控制器负责推理图、已训练模型版本管理和 LLM 模型缓存，其中 LocalModel Controller 在各个节点上创建 PersistentVolumeClaim，并协调从 S3、GCS 等外部存储下载模型，以缩短大模型的下载时间。<sup>[4](https://kserve.github.io/website/docs/concepts/architecture/control-plane)</sup>

**标准部署模式**使用普通的 Kubernetes Deployment、Service 和网络配置，推荐用于大多数生产环境，包括 LLM 服务。扩缩使用水平 Pod 自动扩缩器（HPA），基于 CPU、内存和自定义指标，可选配 KEDA 以实现基于队列、数据库等外部指标的事件驱动扩缩。<sup>[4](https://kserve.github.io/website/docs/concepts/architecture/control-plane)</sup> 在 RawDeployment 模式下，自动扩缩通过 `spec.scaling.hpa` 配置，默认不支持缩容至零。<sup>[6](https://docs.nvidia.com/nim-operator/latest/kserve.html)</sup>

**Knative 模式**基于 Knative Serving 实现事件驱动和缩容至零。每个 Pod 包含一个 Knative 队列代理，用于指标采集和请求处理；修订版本提供自动版本管理和流量拆分；Knative 自动扩缩器（KPA）在无流量时将 Pod 缩容至零副本，由 activator 组件负责请求排队和 Pod 激活。<sup>[4](https://kserve.github.io/website/docs/concepts/architecture/control-plane)</sup> 其代价包括首次请求的冷启动延迟、Knative 组件带来的额外运维复杂性、队列代理的资源开销，以及对 Istio 或 Kourier 的网络依赖。<sup>[4](https://kserve.github.io/website/docs/concepts/architecture/control-plane)</sup> Knative Serving 本身在启用缩容至零且无流量时会将应用缩容至零副本，流量恢复时再扩容。<sup>[7](https://knative.dev/docs/serving/configuring-autoscaling/)</sup>

## 自动扩缩行为

在无服务器模式下，自动扩缩响应传入的请求负载，KServe 默认将 `minReplicas` 设为 1。将 `minReplicas` 设为 0 即可启用缩容至零，这一配置尤其针对 GPU 上的模型服务，因为空闲 GPU 容量的成本很高。<sup>[8](https://kserve.github.io/archive/0.15/modelserving/autoscaling/autoscaling/)</sup> `ContainerConcurrency` 设置决定 InferenceService 每个副本在给定时间内可同时处理的请求数；它是硬性限制，当并发数达到上限时，多余的请求会被缓冲，直到有足够容量释放。<sup>[8](https://kserve.github.io/archive/0.15/modelserving/autoscaling/autoscaling/)</sup>

在 Knative 下，缩容至零是一个分阶段过程：自动扩缩器指示 ServerlessServices（SKS）资源切换到 Proxy 模式，使流量指向 activator；系统持续探测公共服务，直到 activator 能够响应；只有在经过可配置的缩容至零宽限期后，最后一个 Pod 才会被移除。<sup>[9](https://github.com/knative/serving/blob/main/docs/scaling/SYSTEM.md)</sup>

## 网络

KServe 推荐使用 Kubernetes Gateway API 进行网络配置，理由是它支持流量拆分、金丝雀部署和蓝绿部署，原生支持 HTTP/2 和 gRPC，并可通过 HTTPRoute 和 Gateway 资源实现厂商中立的配置。Kubernetes Ingress 仍为向后兼容而受支持，但存在明显限制：不支持基于百分比的流量拆分，不支持 explain 端点，不支持基于路径的路由，且不同 Ingress 控制器之间存在实现差异。<sup>[4](https://kserve.github.io/website/docs/concepts/architecture/control-plane)</sup> 在 Knative 模式下，Istio 等 Knative 网关为每个模型修订版本提供稳定域名，并内置队列系统以处理过载。<sup>[6](https://docs.nvidia.com/nim-operator/latest/kserve.html)</sup>

## ModelMesh Serving

ModelMesh Serving 是 KServe 的子项目，用于高密度多模型服务。一个控制器 Pod 编排一个或多个模型运行时 Deployment，单个 Kubernetes Service 接收跨所有运行时的推理请求。所有 Pod 中的 model-mesh 容器组成一个集群，控制和数据平面请求在其中路由；每个 Pod 中特定于运行时的模型服务器从内存中并发加载和服务多个不同模型。每个运行时 Deployment 的 Pod 数量是一个全局配置参数，默认值为 2，某个 ServingRuntime 的 Pod 仅在 InferenceService 需要时才会启动。<sup>[5](https://github.com/kserve/modelmesh-serving/blob/main/docs/README.md)</sup> 对于每个 InferenceService predictor，控制器在 model-mesh 中注册一个虚拟模型（VModel），该虚拟模型解析到最近一次成功加载的具体模型，其名称包含 predictor spec 的哈希值。<sup>[10](https://github.com/kserve/modelmesh-serving/blob/main/docs/architecture/README.md)</sup> ModelMesh Serving 统一采用 KServe v2 数据平面 API，内置模型类型同时支持 gRPC 和 REST 版本。<sup>[5](https://github.com/kserve/modelmesh-serving/blob/main/docs/README.md)</sup>

## 推理运行时与协议

KServe 通过可插拔运行时支持预测推理和生成式推理。对于大语言模型，[Hugging Face](https://www.edgepedia.org/zh/hugging-face) 运行时在文本生成和文本到文本生成任务中默认使用 vLLM 后端，采用分页注意力、连续批处理和优化的 CUDA 内核等推理优化技术，以缩短首字延迟并提高令牌吞吐量；其他任务类型通过 KServe 的开放推理协议（V1 API）提供服务。<sup>[11](https://kserve.github.io/archive/0.13/modelserving/v1beta1/llm/huggingface/)</sup> 开放推理协议即 V2 规范，是一个 REST 和 gRPC 推理 API，Triton、TensorFlow Serving 和 TorchServe 也实现了该协议，因此它成为跨服务工具的持久集成点。<sup>[12](https://dreaming.press/posts/2026-06-22-bentoml-vs-ray-serve-vs-kserve.html)</sup> 第三方 Operator 在这些接口之上构建；例如 NVIDIA NIM Operator 配置 KServe InferenceService 来管理 NIM 容器的部署、升级、入口和自动扩缩，并使用 NIMCache 缓存来减少初始推理时间和自动扩缩延迟。<sup>[6](https://docs.nvidia.com/nim-operator/latest/kserve.html)</sup>

## 生态定位

KServe 已集成到 Kubeflow 生态系统中，后者与 CNCF 技术协同工作，包括用于监控的 [Prometheus](https://www.edgepedia.org/zh/prometheus)、KServe、Feast 和 Kueue，以及用于安全服务通信的 Istio。<sup>[13](https://www.cncf.io/announcements/2026/08/17/cncf-announces-kubeflows-graduation-solidifying-the-standard-for-cloud-native-ai-operations/)</sup> Kubeflow 社区发行版 26.03.1 版本包含 v0.18.0 的 KServe Web 应用。<sup>[14](https://www.cncf.io/blog/2026/07/28/kubeflow-unveils-new-cloud-native-innovations-to-supercharge-ai/)</sup> 与 Seldon Core v2 和 BentoML 等替代方案相比，KServe 的显著特点是其与 CNCF 的一致性以及通过 Knative 原生实现的缩容至零；Seldon Core v2 面向带漂移检测的多步推理流水线，BentoML 面向 Kubernetes 之外的 Python 优先打包。<sup>[2](https://www.spheron.network/blog/kserve-vs-seldon-core-vs-bentoml-kubernetes-ml-serving-guide/)</sup>

研究持续在此平台之上展开。一项 2025 年的冷启动模型交付实证研究在 KServe 中实现了两条基于 OCI 的新交付路径：`oci+native://`，依据 KEP-4639 将模型镜像作为 Kubernetes 镜像卷挂载，已合入上游；以及 `oci+fetch://`，在存储初始化器中拉取 OCI 制品，测试所用制品大小对应 1B、7B 和 70B 级模型的 fp16 权重（2 至 140 GB）。<sup>[15](https://arxiv.org/abs/2607.16596)</sup>

## References

1. [KServe: The next generation of KFServing, Kubeflow blog (Dan Sun and Animesh Singh, 27 September 2021)](https://blog.kubeflow.org/release/official/2021/09/27/kfserving-transition.html)
2. [KServe vs Seldon Core vs BentoML on GPU Cloud: Kubernetes ML Serving Guide, Spheron Blog](https://www.spheron.network/blog/kserve-vs-seldon-core-vs-bentoml-kubernetes-ml-serving-guide/)
3. [KServe Resources, KServe documentation](https://kserve.github.io/website/docs/concepts/resources)
4. [Control Plane, KServe documentation](https://kserve.github.io/website/docs/concepts/architecture/control-plane)
5. [ModelMesh Serving documentation README, kserve/modelmesh-serving GitHub](https://github.com/kserve/modelmesh-serving/blob/main/docs/README.md)
6. [KServe Support on NIM Operator, NVIDIA NIM Operator documentation](https://docs.nvidia.com/nim-operator/latest/kserve.html)
7. [About autoscaling, Knative Serving documentation](https://knative.dev/docs/serving/configuring-autoscaling/)
8. [Knative Autoscaler (KPA), KServe documentation archive 0.15](https://kserve.github.io/archive/0.15/modelserving/autoscaling/autoscaling/)
9. [Knative Serving Autoscaling System (SYSTEM.md), knative/serving GitHub](https://github.com/knative/serving/blob/main/docs/scaling/SYSTEM.md)
10. [ModelMesh Serving architecture overview, kserve/modelmesh-serving GitHub](https://github.com/kserve/modelmesh-serving/blob/main/docs/architecture/README.md)
11. [Hugging Face runtime overview, KServe documentation archive 0.13](https://kserve.github.io/archive/0.13/modelserving/v1beta1/llm/huggingface/)
12. [BentoML vs Ray Serve vs KServe: Choosing a Model-Serving Framework, Dreaming Press](https://dreaming.press/posts/2026-06-22-bentoml-vs-ray-serve-vs-kserve.html)
13. [CNCF Announces Kubeflow's Graduation, CNCF (17 August 2026)](https://www.cncf.io/announcements/2026/08/17/cncf-announces-kubeflows-graduation-solidifying-the-standard-for-cloud-native-ai-operations/)
14. [Kubeflow unveils new cloud native innovations to supercharge AI, CNCF blog (28 July 2026)](https://www.cncf.io/blog/2026/07/28/kubeflow-unveils-new-cloud-native-innovations-to-supercharge-ai/)
15. [Cold-Start Model Delivery in Kubernetes Inference Serving: An Empirical Study of OCI-Based Distribution and Its Integrity, arXiv:2607.16596](https://arxiv.org/abs/2607.16596)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Machine learning and neural computation › Neural networks and deep learning › Deep learning software and hardware › Model deployment and serving

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/kserve

English original: https://www.edgepedia.org/kserve
