k8s源码分析之外部api(官方单独维护api部分-https://github.com/kubernetes/api)
E:\k8s源码\kubernetes-1.10.13\kubernetes-1.10.13\staging\src\k8s.io\api(外部类型的apiserver)
官方已单独维护api部分
https://github.com/kubernetes/api#recommended-use
api
Schema of the external API types that are served by the Kubernetes API server.
Kubernetes API服务器提供的外部API类型的架构。
Purpose
This library is the canonical location of the Kubernetes API definition. Most likely interaction with this repository is as a dependency of client-go.
这个库是Kubernetes API定义的典型的地方。与该库的交互最有可能是依靠client-go(第三方库)。
It is published separately to avoid diamond dependency problems for users who depend on more than one of k8s.io/client-go
, k8s.io/apimachinery
, k8s.io/apiserver
...
它是单独发布的,以避免用户依赖多个k8s.io/client-go, k8s.io/apimachinery, k8s.io/apiserver..的出现菱形依赖问题。
Recommended Use(推荐使用)
We recommend using the go types in this repo. You may serialize them directly to JSON.
我们建议使用go types在这个仓库中。您可以将它们直接序列化为JSON。
If you want to store or interact with proto-formatted Kubernetes API objects, we recommend using the "official" serialization stack in k8s.io/apimachinery
.
如果要存储或交互proto-formatted Kubernetes API objects(原始格式的Kubernetes API对象),建议使用在k8s.io/apimachinery里面的“官方”序列化堆栈。
Directly serializing these types to proto will not result in data that matches the wire format or is compatible with other kubernetes ecosystem tools.
将这些types直接序列化为proto不会产生与wire格式匹配的数据,或也不会产生与其他kubernetes生态系统工具兼容的数据。
The reason is that the wire format includes a magic prefix and an envelope proto. Please see: https://kubernetes.io/docs/reference/using-api/api-concepts/#protobuf-encoding
原因是wire格式包括一个magic前缀和一个信封proto。请参见:https://kubernetes.io/docs/reference/using-api/api-concepts/#protobuf-encoding
For the same reason, we do not recommend embedding these proto objects within your own proto definitions. It is better to store Kubernetes objects as byte arrays, in the wire format,
which is self-describing. This permits you to use either JSON or binary (proto) wire formats without code changes.
It will be difficult for you to operate on both Custom Resources and built-in types otherwise.
出于同样的原因,我们不建议将这些proto对象嵌入到您自己的proto定义中。最好将Kubernetes对象存储为字节数组,采用自描述的wire格式。
这允许您在不更改代码的情况下使用JSON或二进制(proto)wire格式。否则,您很难同时对自定义资源和内置类型进行操作
Compatibility(兼容性)
Branches track Kubernetes branches and are compatible with that repo.
分支跟踪Kubernetes分支,并兼容此仓库。
Where does it come from? 它来自哪里?
api is synced from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api.
Code changes are made in that location, merged into k8s.io/kubernetes and later synced here. api是从https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api.
代码更改在该位置进行,并合并到k8s.io/kubernetes ,以后在这里同步。
Things you should NOT do
你不应该做的事情
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api is synced to k8s.io/api. All changes must be made in the former. The latter is read-only.
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api已同步到 k8s.io/api。所有的改变都必须在前者中进行。后者是只读的。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?