The REST API is the fundamental fabric of Kubernetes. All operations and communications between components, and external user commands are REST API calls that the API Server handles. Consequently, everything in the Kubernetes platform is treated as an API object and has a corresponding entry in the API.
REST API是Kubernetes的基本結構话原。組件和外部用戶命令之間的所有操作和通信都是API服務器處理的REST API調用晕窑。因此,Kubernetes平臺中的所有內容都被視為API對象敛瓷,并且在API中有相應的條目学赛。
Most operations can be performed through the kubectl command-line interface or other command-line tools, such as kubeadm, which in turn use the API. However, you can also access the API directly using REST calls.
大多數(shù)操作都可以通過kubectl命令行界面或其他命令行工具(如kubeadm)執(zhí)行年堆,而這些工具又使用API。不過盏浇,您也可以使用REST調用直接訪問API变丧。
Consider using one of the client libraries if you are writing an application using the Kubernetes API.
如果正在使用Kubernetes API編寫應用程序,請考慮使用其中一個客戶機庫缠捌。
API versioning
To eliminate fields or restructure resource representations, Kubernetes supports multiple API versions, each at a different API path. For example: /api/v1 or /apis/extensions/v1beta1.
為了消除字段或重構資源表示锄贷,Kubernetes支持多個API版本,每個版本都位于不同的API路徑曼月。例如:/api/v1
或/api/ extensions/v1beta1
谊却。
The version is set at the API level rather than at the resource or field level to:
版本在API級別而不是在資源或字段級別設置:
- Ensure that the API presents a clear and consistent view of system resources and behavior.確保API對系統(tǒng)資源和行為提供清晰一致的視圖。
- Enable control access to end-of-life and/or experimental APIs.啟用對生命終止和/或實驗api的控制訪問哑芹。
The JSON and Protobuf serialization schemas follow the same guidelines for schema changes. The following descriptions cover both formats.
對于模式更改炎辨,JSON和Protobuf序列化模式遵循相同的指導原則。下面的描述涵蓋了這兩種格式聪姿。
Note: The API versioning and software versioning are indirectly related. The API and release versioning proposal describes the relationship between API versioning and software versioning. API版本控制和軟件版本控制是間接相關的碴萧。API和發(fā)布版本控制建議描述了API版本控制和軟件版本控制之間的關系乙嘀。
Different API versions indicate different levels of stability and support. You can find more information about the criteria for each level in the API Changes documentation.
不同的API版本表示不同級別的穩(wěn)定性和支持。您可以在API Changes文檔中找到關于每個級別的標準的更多信息破喻。
Here’s a summary of each level:
Alpha:
- The version names contain alpha (for example, v1alpha1).
- The software may contain bugs. Enabling a feature may expose bugs. A feature may be disabled by default.
- The support for a feature may be dropped at any time without notice.
- The API may change in incompatible ways in a later software release without notice.
- The software is recommended for use only in short-lived testing clusters, due to increased risk of bugs and lack of long-term support.
-版本名稱包含alpha(例如虎谢,v1alpha1)。
-軟件可能有漏洞曹质。啟用某個特性可能會暴露bug婴噩。默認情況下可以禁用某個特性。
-功能的支持可能會在任何時候被取消而不另行通知羽德。
-在以后的軟件版本中几莽,API可能會以不兼容的方式更改,而無需通知宅静。
-由于bug風險增加和缺乏長期支持章蚣,建議只在短期測試集群中使用該軟件。
Beta:
- The version names contain beta (for example, v2beta3).
- The software is well tested. Enabling a feature is considered safe. Features are enabled by default.
- The support for a feature will not be dropped, though the details may change.
- The schema and/or semantics of objects may change in incompatible ways in a subsequent beta or stable release. When this happens, migration instructions are provided. - This may require deleting, editing, and re-creating API objects. The editing process may require some thought. This may require downtime for applications that rely on the feature.
- The software is recommended for only non-business-critical uses because of potential for incompatible changes in subsequent releases. If you have multiple clusters which can be upgraded independently, you may be able to relax this restriction.
-版本名稱包含beta(例如姨夹,v2beta3)纤垂。
-該軟件經(jīng)過良好測試。啟用特性被認為是安全的磷账。默認情況下啟用特性洒忧。
-不會取消對功能的支持,但細節(jié)可能會有所改變够颠。
-在隨后的beta版或穩(wěn)定版本中,對象的模式和/或語義可能會發(fā)生不兼容的變化榄鉴。當這種情況發(fā)生時履磨,將提供遷移指令。
-這可能需要刪除庆尘、編輯和重新創(chuàng)建API對象剃诅。編輯過程可能需要一些思考。對于依賴該特性的應用程序驶忌,這可能需要停機矛辕。
-由于后續(xù)版本中可能出現(xiàn)不兼容的更改,本軟件僅推薦非業(yè)務關鍵用途付魔。如果您有多個可以獨立升級的集群聊品,則可以放寬這一限制。
Note: Try the beta features and provide feedback. After the features exit beta, it may not be practical to make more changes.
注意:嘗試beta特性并提供反饋几苍。在特性退出beta版之后翻屈,進行更多更改可能不太實際。
Stable:
- The version name is vX where X is an integer.
- The stable versions of features appear in released software for many subsequent versions.
-版本名是vX妻坝,其中X是整數(shù)伸眶。
-穩(wěn)定版本的功能出現(xiàn)在發(fā)布的軟件為許多后續(xù)版本惊窖。
API groups
API groups make it easier to extend the Kubernetes API. The API group is specified in a REST path and in the apiVersion field of a serialized object.
API組使擴展Kubernetes API變得更容易。API組在REST路徑和序列化對象的apiVersion字段中指定厘贼。
Currently, there are several API groups in use:
The core (also called legacy) group, which is at REST path /api/v1 and is not specified as part of the apiVersion field, for example, apiVersion: v1.
The named groups are at REST path /apis/VERSION, and use apiVersion: VERSION (for example, apiVersion: batch/v1). You can find the full list of supported API groups in Kubernetes API reference.
核心(也稱為遺留)組界酒,它位于REST path /api/v1,并且沒有指定為apiVersion字段的一部分嘴秸,例如毁欣,apiVersion: v1。
命名組位于REST path /api /VERSION赁遗,并使用apiVersion: VERSION(例如署辉,apiVersion: batch/v1)。您可以在Kubernetes API引用中找到支持的API組的完整列表岩四。
The two paths that support extending the API with custom resources are:
CustomResourceDefinition for basic CRUD needs.基本CRUD需求的CustomResourceDefinition哭尝。
aggregator for a full set of Kubernetes API semantics to implement their own apiserver.聚合器為一組完整的Kubernetes API語義實現(xiàn)自己的apiserver。
Enabling API groups
Certain resources and API groups are enabled by default. You can enable or disable them by setting --runtime-config on the apiserver. --runtime-config accepts comma separated values. For example: - to disable batch/v1, set --runtime-config=batch/v1=false - to enable batch/v2alpha1, set --runtime-config=batch/v2alpha1 The flag accepts comma separated set of key=value pairs describing runtime configuration of the apiserver.
默認情況下啟用某些資源和API組剖煌。您可以通過在apiserver
上設置—runtime-config
來啟用或禁用它們材鹦。——runtime-config
接受逗號分隔的值。例如:-要禁用batch/v1
, set -runtime-config=batch/v1=false
-要啟用batch/v2alpha1
, set -runtime-config=batch/v2alpha1
標志接受逗號分隔的一組鍵值對耕姊,它們描述apiserver的運行時配置桶唐。
Note: When you enable or disable groups or resources, you need to restart the apiserver and controller-manager to pick up the --runtime-config changes.
當您啟用或禁用組或資源時,您需要重新啟動apiserver
和controller-manager
來接受—runtime-config
更改茉兰。
Enabling resources in the groups
DaemonSets, Deployments, HorizontalPodAutoscalers, Ingress, Jobs and ReplicaSets are enabled by default. You can enable other extensions resources by setting --runtime-config on apiserver. --runtime-config accepts comma separated values. For example, to disable deployments and jobs, set --runtime-config=extensions/v1beta1/deployments=false,extensions/v1beta1/jobs=false
默認情況下尤泽,守護進程集、部署规脸、HorizontalPodAutoscalers坯约、Ingress、作業(yè)和副本集都是啟用的莫鸭。您可以通過在apiserver
上設置—runtime-config
來啟用其他擴展資源闹丐。——runtime-config
接受逗號分隔的值。例如被因,要禁用部署和作業(yè)卿拴,set—runtime-config=extensions/v1beta1/deploy =false,extensions/v1beta1/jobs=false