一、什么是Knative Serverless 平台
Knative(Knative Serving)是 Kubernetes 上的 Serverless 平台,由 Google、Pivotal、IBM、Red Hat、SAP 等社区于 2018 年 7 月联合发布。其核心能力是把 Kubernetes 抽象为 Serverless 体验,通过 Serving 提供自动伸缩、流量切换、Revision 管理,再加 Eventing 提供事件接入与处理。该技术对云原生函数平台、流量灰度、Serverless 体验具有重要意义,也被 Google Cloud Run、IBM Code Engine、阿里云 Knative Serving 等云厂商采纳为标准底座。

二、原理
1. Service CR:用户声明 Knative Service,包含镜像、流量、env 等 → 2. Revision 与 Route:每次配置变更生成新 Revision,Route 在 Revision 间按比例分配流量 → 3. Pod Autoscaler:KPA 基于 RPS/CPU 并发指标伸缩 Pod 到 0/N → 4. Activator:当请求遇到冷 Pod 时由 Activator 排队 → 5. Eventing:Broker/Trigger 解耦事件源与消费者 → 6. Domain 映射:自动注入 *.example.com 网络路由
三、信息卡片
| 中文名 | Knative Serverless 平台 |
| 英文名 | Knative Serverless Platform |
| 缩写 | Knative |
| 别名 | Knative、Knative Serving |
| 提出者 | Google / Pivotal / IBM / Red Hat / SAP |
| 提出时间 | 2018 年 7 月 |
| 所属类别 | IT行业 > IT基础架构与开发 |
| 核心技术 | Knative、Knative Serving |
| 主要应用 | 见 applications 段 |
四、历史时间线
2018 年 7 月:Google / Pivotal / IBM / Red Hat / SAP 等联合发布 Knative
- 2019 年:Knative 加入 CNCF,Kubernetes 1.14 引入 Knative 集成
- 2020 年:Knative 1.0 GA
- 2021 年:Knative Eventing 引入 CloudEvent 标准
- 2022 年:Knative 0.26/1.x 系列引入 KEDA-style 0→N 缩放
- 2024—2025 年:Knative 被 Google Cloud Run、IBM Code Engine 等云函数底座广泛使用
五、分类
- 按组件:Serving(请求路由 + 自动伸缩)vs Eventing(事件路由)
- 按伸缩:KPA(Pod Autoscaler,基于并发/RPS)vs HPA 自定义
- 按流量:Revision 100/0 配置(蓝绿)vs 50/50 灰度 vs tag-based 流控
- 按使用形态:本地 Knative vs 厂商托管(Cloud Run/Code Engine)
- 按事件源:Kafka/RabbitMQ/PingSource/自定义 Source
六、应用场景
- Google Cloud Run:Knative 是其上游核心
- IBM Code Engine:基于 Knative 的托管 Serverless
- API 灰度发布:在 Revision 维度做 1%→100% 流量迁移
- AI 推理场景:Function 化部署 LLM 推理 API
- Serverless ETL:ETL 函数随事件触发
- 企业内部函数平台:把 Knative 部署在私有 Kubernetes 上
七、优缺点
- 优点:
- 在 Kubernetes 上提供开箱即用 Serverless 体验
- Revision 模型使蓝绿、灰度、A/B 测试原生支持
- Knative Eventing 与 CloudEvents 标准一致
- 已被 Google Cloud Run 等大型厂商生产验证
- Serving 与 Eventing 双组件可分立使用
- 缺点:
- 组件较多(Serving/Eventing/CLI/Plugin)治理复杂度高
- Activator 的冷启动链路增加一跳延迟
- KPA 配置在某些极端 RPS 模型下不如自研 HPA
- 文档与版本迭代较快,旧文档对新版本可能误导
八、常见误区
- Knative = FaaS(错:Knative 是平台,可承载 FaaS 风格体验)
- Knative 仅 Google 主导(错:开源治理,多厂商参与)
- Knative 必须绑定 Istio(错:自 0.7 起支持 Kou 网关选型)
- Knative 自动 0→N(对:基于并发阈值可在空闲时缩到 0)
九、关联概念
- 父概念:Kubernetes、Docker 容器化、服务网格 Service Mesh
- 子概念:云原生 Cloud Native、混合云 Hybrid Cloud、Serverless
- 兄弟概念:Istio、多云 Multi-Cloud、微服务 Microservices
- 对比概念:Knative Serverless Platform vs Cloud Native、Knative Serverless Platform vs Infrastructure as Code