Skip to content

Commit 96d89ba

Browse files
authored
Added examples of Lists to api-concepts (#28608)
* Added List descriptions to api-concepts * Corrected note and example per comments
1 parent 1376909 commit 96d89ba

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

content/en/docs/reference/using-api/api-concepts.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,77 @@ more remaining items and the API server does not include a `remainingItemCount`
208208
field in its response. The intended use of the `remainingItemCount` is estimating
209209
the size of a collection.
210210

211+
## Lists
212+
213+
There are dozens of list types (such as `PodList`, `ServiceList`, and `NodeList`) defined in the Kubernetes API.
214+
You can get more information about each list type from the [Kubernetes API](https://kubernetes.io/docs/reference/kubernetes-api/) documentation.
215+
216+
When you query the API for a particular type, all items returned by that query are of that type. For example, when you
217+
ask for a list of services, the list type is shown as `kind: ServiceList` and each item in that list represents a single Service. For example:
218+
219+
```console
220+
221+
GET /api/v1/services
222+
---
223+
{
224+
"kind": "ServiceList",
225+
"apiVersion": "v1",
226+
"metadata": {
227+
"resourceVersion": "2947301"
228+
},
229+
"items": [
230+
{
231+
"metadata": {
232+
"name": "kubernetes",
233+
"namespace": "default",
234+
...
235+
"metadata": {
236+
"name": "kube-dns",
237+
"namespace": "kube-system",
238+
...
239+
```
240+
241+
Some tools, such as `kubectl` provide another way to query the Kubernetes API. Because the output of `kubectl` might include multiple list types, the list of items is represented as `kind: List`. For example:
242+
243+
```console
244+
245+
$ kubectl get services -A -o yaml
246+
247+
apiVersion: v1
248+
kind: List
249+
metadata:
250+
resourceVersion: ""
251+
selfLink: ""
252+
items:
253+
- apiVersion: v1
254+
kind: Service
255+
metadata:
256+
creationTimestamp: "2021-06-03T14:54:12Z"
257+
labels:
258+
component: apiserver
259+
provider: kubernetes
260+
name: kubernetes
261+
namespace: default
262+
...
263+
- apiVersion: v1
264+
kind: Service
265+
metadata:
266+
annotations:
267+
prometheus.io/port: "9153"
268+
prometheus.io/scrape: "true"
269+
creationTimestamp: "2021-06-03T14:54:14Z"
270+
labels:
271+
k8s-app: kube-dns
272+
kubernetes.io/cluster-service: "true"
273+
kubernetes.io/name: CoreDNS
274+
name: kube-dns
275+
namespace: kube-system
276+
```
277+
278+
{{< note >}}
279+
Keep in mind that the Kubernetes API does not have a `kind: List` type. `kind: List` is an internal mechanism type for lists of mixed resources and should not be depended upon.
280+
{{< /note >}}
281+
211282

212283
## Receiving resources as Tables
213284

0 commit comments

Comments
 (0)