Skip to content

Commit d8e0a2c

Browse files
authored
Merge pull request #21163 from sftim/20200524_revise_kubernetes_api_concept
Revise Kubernetes API concept page
2 parents a2cf355 + 1b78735 commit d8e0a2c

File tree

1 file changed

+94
-56
lines changed

1 file changed

+94
-56
lines changed

content/en/docs/concepts/overview/kubernetes-api.md

Lines changed: 94 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,73 +11,94 @@ card:
1111

1212
{{% capture overview %}}
1313

14-
Overall API conventions are described in the [API conventions doc](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md).
14+
The core of Kubernetes' {{< glossary_tooltip text="control plane" term_id="control-plane" >}}
15+
is the {{< glossary_tooltip text="API server" term_id="kube-apiserver" >}}. The API server
16+
exposes an HTTP API that lets end users, different parts of your cluster, and external components
17+
communicate with one another.
1518

16-
API endpoints, resource types and samples are described in [API Reference](/docs/reference).
19+
The Kubernetes API lets you query and manipulate the state of objects in the Kubernetes API
20+
(for example: Pods, Namespaces, ConfigMaps, and Events).
1721

18-
Remote access to the API is discussed in the [Controlling API Access doc](/docs/reference/access-authn-authz/controlling-access/).
19-
20-
The Kubernetes API also serves as the foundation for the declarative configuration schema for the system. The [kubectl](/docs/reference/kubectl/overview/) command-line tool can be used to create, update, delete, and get API objects.
21-
22-
Kubernetes also stores its serialized state (currently in [etcd](https://coreos.com/docs/distributed-configuration/getting-started-with-etcd/)) in terms of the API resources.
23-
24-
Kubernetes itself is decomposed into multiple components, which interact through its API.
22+
API endpoints, resource types and samples are described in the [API Reference](/docs/reference/kubernetes-api/).
2523

2624
{{% /capture %}}
2725

28-
2926
{{% capture body %}}
3027

3128
## API changes
3229

33-
In our experience, any system that is successful needs to grow and change as new use cases emerge or existing ones change. Therefore, we expect the Kubernetes API to continuously change and grow. However, we intend to not break compatibility with existing clients, for an extended period of time. In general, new API resources and new resource fields can be expected to be added frequently. Elimination of resources or fields will require following the [API deprecation policy](/docs/reference/using-api/deprecation-policy/).
34-
35-
What constitutes a compatible change and how to change the API are detailed by the [API change document](https://git.k8s.io/community/contributors/devel/sig-architecture/api_changes.md).
30+
Any system that is successful needs to grow and change as new use cases emerge or existing ones change.
31+
Therefore, Kubernetes has design features to allow the Kubernetes API to continuously change and grow.
32+
The Kubernetes project aims to _not_ break compatibility with existing clients, and to maintain that
33+
compatibility for a length of time so that other projects have an opportunity to adapt.
3634

37-
## OpenAPI and Swagger definitions
35+
In general, new API resources and new resource fields can be added often and frequently.
36+
Elimination of resources or fields requires following the
37+
[API deprecation policy](/docs/reference/using-api/deprecation-policy/).
3838

39-
Complete API details are documented using [OpenAPI](https://www.openapis.org/).
40-
41-
Starting with Kubernetes 1.10, the Kubernetes API server serves an OpenAPI spec via the `/openapi/v2` endpoint.
42-
The requested format is specified by setting HTTP headers:
43-
44-
Header | Possible Values
45-
------ | ---------------
46-
Accept | `application/json`, `application/[email protected]+protobuf` (the default content-type is `application/json` for `*/*` or not passing this header)
47-
Accept-Encoding | `gzip` (not passing this header is acceptable)
39+
What constitutes a compatible change, and how to change the API, are detailed in
40+
[API changes](https://git.k8s.io/community/contributors/devel/sig-architecture/api_changes.md#readme).
4841

49-
Prior to 1.14, format-separated endpoints (`/swagger.json`, `/swagger-2.0.0.json`, `/swagger-2.0.0.pb-v1`, `/swagger-2.0.0.pb-v1.gz`)
50-
serve the OpenAPI spec in different formats. These endpoints are deprecated, and are removed in Kubernetes 1.14.
42+
## OpenAPI specification {#api-specification}
5143

52-
**Examples of getting OpenAPI spec**:
44+
Complete API details are documented using [OpenAPI](https://www.openapis.org/).
5345

54-
Before 1.10 | Starting with Kubernetes 1.10
55-
----------- | -----------------------------
56-
GET /swagger.json | GET /openapi/v2 **Accept**: application/json
57-
GET /swagger-2.0.0.pb-v1 | GET /openapi/v2 **Accept**: application/[email protected]+protobuf
58-
GET /swagger-2.0.0.pb-v1.gz | GET /openapi/v2 **Accept**: application/[email protected]+protobuf **Accept-Encoding**: gzip
46+
The Kubernetes API server serves an OpenAPI spec via the `/openapi/v2` endpoint.
47+
You can request the response format using request headers as follows:
48+
49+
<table>
50+
<thead>
51+
<tr>
52+
<th>Header</th>
53+
<th style="min-width: 50%;">Possible values</th>
54+
<th>Notes</th>
55+
</tr>
56+
</thead>
57+
<tbody>
58+
<tr>
59+
<td><code>Accept-Encoding</code></td>
60+
<td><code>gzip</code></td>
61+
<td><em>not supplying this header is also acceptable</em></td>
62+
</tr>
63+
<tr>
64+
<td rowspan="3"><code>Accept</code></td>
65+
<td><code>application/[email protected]+protobuf</code></td>
66+
<td><em>mainly for intra-cluster use</em></td>
67+
</tr>
68+
<tr>
69+
<td><code>application/json</code></td>
70+
<td><em>default</em></td>
71+
</tr>
72+
<tr>
73+
<td><code>*</code></td>
74+
<td><em>serves </em><code>application/json</code></td>
75+
</tr>
76+
</tbody>
77+
<caption>Valid request header values for OpenAPI v2 queries</caption>
78+
</table>
5979

6080
Kubernetes implements an alternative Protobuf based serialization format for the API that is primarily intended for intra-cluster communication, documented in the [design proposal](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/protobuf.md) and the IDL files for each schema are located in the Go packages that define the API objects.
6181

62-
Prior to 1.14, the Kubernetes apiserver also exposes an API that can be used to retrieve
63-
the [Swagger v1.2](http://swagger.io/) Kubernetes API spec at `/swaggerapi`.
64-
This endpoint is deprecated, and was removed in Kubernetes 1.14.
65-
6682
## API versioning
6783

6884
To make it easier to eliminate fields or restructure resource representations, Kubernetes supports
6985
multiple API versions, each at a different API path, such as `/api/v1` or
7086
`/apis/extensions/v1beta1`.
7187

72-
We chose to version at the API level rather than at the resource or field level to ensure that the API presents a clear, consistent view of system resources and behavior, and to enable controlling access to end-of-life and/or experimental APIs. The JSON and Protobuf serialization schemas follow the same guidelines for schema changes - all descriptions below cover both formats.
88+
Versioning is done at the API level rather than at the resource or field level to ensure that the
89+
API presents a clear, consistent view of system resources and behavior, and to enable controlling
90+
access to end-of-life and/or experimental APIs.
7391

74-
Note that API versioning and Software versioning are only indirectly related. The [API and release
75-
versioning proposal](https://git.k8s.io/community/contributors/design-proposals/release/versioning.md) describes the relationship between API versioning and
76-
software versioning.
92+
The JSON and Protobuf serialization schemas follow the same guidelines for schema changes - all descriptions below cover both formats.
7793

94+
Note that API versioning and Software versioning are only indirectly related. The
95+
[Kubernetes Release Versioning](https://git.k8s.io/community/contributors/design-proposals/release/versioning.md)
96+
proposal describes the relationship between API versioning and software versioning.
7897

7998
Different API versions imply different levels of stability and support. The criteria for each level are described
80-
in more detail in the [API Changes documentation](https://git.k8s.io/community/contributors/devel/sig-architecture/api_changes.md#alpha-beta-and-stable-versions). They are summarized here:
99+
in more detail in the
100+
[API Changes](https://git.k8s.io/community/contributors/devel/sig-architecture/api_changes.md#alpha-beta-and-stable-versions)
101+
documentation. They are summarized here:
81102

82103
- Alpha level:
83104
- The version names contain `alpha` (e.g. `v1alpha1`).
@@ -101,35 +122,36 @@ in more detail in the [API Changes documentation](https://git.k8s.io/community/c
101122

102123
## API groups
103124

104-
To make it easier to extend the Kubernetes API, we implemented [*API groups*](https://git.k8s.io/community/contributors/design-proposals/api-machinery/api-group.md).
125+
To make it easier to extend its API, Kubernetes implements [*API groups*](https://git.k8s.io/community/contributors/design-proposals/api-machinery/api-group.md).
105126
The API group is specified in a REST path and in the `apiVersion` field of a serialized object.
106127

107-
Currently there are several API groups in use:
128+
There are several API groups in a cluster:
108129

109-
1. The *core* group, often referred to as the *legacy group*, is at the REST path `/api/v1` and uses `apiVersion: v1`.
130+
1. The *core* group, also referred to as the *legacy* group, is at the REST path `/api/v1` and uses `apiVersion: v1`.
110131

111-
1. The named groups are at REST path `/apis/$GROUP_NAME/$VERSION`, and use `apiVersion: $GROUP_NAME/$VERSION`
112-
(e.g. `apiVersion: batch/v1`). Full list of supported API groups can be seen in [Kubernetes API reference](/docs/reference/).
132+
1. *Named* groups are at REST path `/apis/$GROUP_NAME/$VERSION`, and use `apiVersion: $GROUP_NAME/$VERSION`
133+
(e.g. `apiVersion: batch/v1`). The Kubernetes [API reference](/docs/reference/kubernetes-api/) has a
134+
full list of available API groups.
113135

114-
115-
There are two supported paths to extending the API with [custom resources](/docs/concepts/api-extension/custom-resources/):
136+
There are two paths to extending the API with [custom resources](/docs/concepts/api-extension/custom-resources/):
116137

117138
1. [CustomResourceDefinition](/docs/tasks/access-kubernetes-api/extend-api-custom-resource-definitions/)
118-
is for users with very basic CRUD needs.
119-
1. Users needing the full set of Kubernetes API semantics can implement their own apiserver
139+
lets you declaratively define how the API server should provide your chosen resource API.
140+
1. You can also [implement your own extension API server](/docs/tasks/access-kubernetes-api/setup-extension-api-server/)
120141
and use the [aggregator](/docs/tasks/access-kubernetes-api/configure-aggregation-layer/)
121142
to make it seamless for clients.
122143

123-
124144
## Enabling or disabling API groups
125145

126-
Certain resources and API groups are enabled by default. They can be enabled or disabled by setting `--runtime-config`
127-
on apiserver. `--runtime-config` accepts comma separated values. For example: to disable batch/v1, set
128-
`--runtime-config=batch/v1=false`, to enable batch/v2alpha1, set `--runtime-config=batch/v2alpha1`.
129-
The flag accepts comma separated set of key=value pairs describing runtime configuration of the apiserver.
146+
Certain resources and API groups are enabled by default. They can be enabled or disabled by setting `--runtime-config`
147+
as a command line option to the kube-apiserver.
148+
149+
`--runtime-config` accepts comma separated values. For example: to disable batch/v1, set
150+
`--runtime-config=batch/v1=false`; to enable batch/v2alpha1, set `--runtime-config=batch/v2alpha1`.
151+
The flag accepts comma separated set of key=value pairs describing runtime configuration of the API server.
130152

131-
{{< note >}}Enabling or disabling groups or resources requires restarting apiserver and controller-manager
132-
to pick up the `--runtime-config` changes.{{< /note >}}
153+
{{< note >}}Enabling or disabling groups or resources requires restarting the kube-apiserver and the
154+
kube-controller-manager to pick up the `--runtime-config` changes.{{< /note >}}
133155

134156
## Enabling specific resources in the extensions/v1beta1 group
135157

@@ -139,4 +161,20 @@ For example: to enable deployments and daemonsets, set
139161

140162
{{< note >}}Individual resource enablement/disablement is only supported in the `extensions/v1beta1` API group for legacy reasons.{{< /note >}}
141163

164+
## Persistence
165+
166+
Kubernetes stores its serialized state in terms of the API resources by writing them into
167+
{{< glossary_tooltip term_id="etcd" >}}.
168+
169+
{{% /capture %}}
170+
{{% capture whatsnext %}}
171+
[Controlling API Access](/docs/reference/access-authn-authz/controlling-access/) describes
172+
how the cluster manages authentication and authorization for API access.
173+
174+
Overall API conventions are described in the
175+
[API conventions](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#api-conventions)
176+
document.
177+
178+
API endpoints, resource types and samples are described in the [API Reference](/docs/reference/kubernetes-api/).
179+
142180
{{% /capture %}}

0 commit comments

Comments
 (0)