Listing All Pods in a Specified Namespace
Function
This API is used to list all pods in a specified namespace.
URI
GET /api/v1/namespaces/{namespace}/pods
Table 1 describes the parameters of this API.
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
pretty |
No |
If 'true', then the output is pretty printed. |
|
labelSelector |
No |
A selector to restrict the list of returned objects by their labels. Defaults to everything. |
|
fieldSelector |
No |
A selector to restrict the list of returned objects by their fields. Defaults to everything. |
|
includeUninitialized |
No |
If true, partially initialized resources are included in the response. |
|
watch |
No |
Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. |
|
resourceVersion |
No |
When specified with a watch call, shows changes that occur after that particular version of a resource. Defaults to changes from the beginning of history. |
|
timeoutSeconds |
No |
Timeout for the list/watch call. |
|
namespace |
Yes |
Object name and auth scope, such as for teams and projects. |
Request
N/A
Response
Response parameters:
For the description about response parameters, see Table 4.
Example response:
{
"kind": "PodList",
"apiVersion": "v1",
"metadata": {
"selfLink": "/api/v1/namespaces/default/pods",
"resourceVersion": "1550921"
},
"items": [
{
"metadata": {
"name": "fdsfsd-ddnft",
"generateName": "fdsfsd-",
"namespace": "default",
"selfLink": "/api/v1/namespaces/default/pods/fdsfsd-ddnft",
"uid": "753a45bc-57c4-11e7-afb7-fa163e218692",
"resourceVersion": "1449034",
"creationTimestamp": "2017-06-23T03:31:35Z",
"labels": {
"cce/appgroup": "gfsad",
"name": "fdsfsd"
},
"annotations": {
"kubernetes.io/created-by": "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"ReplicationController\",\"namespace\":\"default\",\"name\":\"fdsfsd\",\"uid\":\"7539c329-57c4-11e7-afb7-fa163e218692\",\"apiVersion\":\"v1\",\"resourceVersion\":\"956153\"}}\n",
"kubernetes.io/limit-ranger": "LimitRanger plugin set: cpu request for container container01"
},
"ownerReferences": [
{
"apiVersion": "v1",
"kind": "ReplicationController",
"name": "fdsfsd",
"uid": "7539c329-57c4-11e7-afb7-fa163e218692",
"controller": true
}
]
},
"spec": {
"volumes": [
{
"name": "default-token-863rh",
"secret": {
"secretName": "default-token-863rh",
"defaultMode": 420
}
}
],
"containers": [
{
"name": "container01",
"image": "10.154.52.159:443/test/apache-php:latest",
"ports": [
{
"containerPort": 80,
"protocol": "TCP"
}
],
"resources": {
"requests": {
"cpu": "100m"
}
},
"volumeMounts": [
{
"name": "default-token-863rh",
"readOnly": true,
"mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
}
],
"terminationMessagePath": "/dev/termination-log",
"imagePullPolicy": "Always"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"serviceAccountName": "default",
"serviceAccount": "default",
"nodeName": "192.168.12.187",
"securityContext": {},
"imagePullSecrets": [
{
"name": "myregistry"
}
]
},
"status": {
"phase": "Running",
"conditions": [
{
"type": "Initialized",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2017-06-23T03:31:36Z"
},
{
"type": "Ready",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2017-06-28T06:34:51Z"
},
{
"type": "PodScheduled",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2017-06-23T03:31:35Z"
}
],
"hostIP": "192.168.12.187",
"podIP": "172.16.56.4",
"startTime": "2017-06-23T03:31:36Z",
"containerStatuses": [
{
"name": "container01",
"state": {
"running": {
"startedAt": "2017-06-28T06:34:46Z"
}
},
"lastState": {},
"ready": true,
"restartCount": 0,
"image": "10.154.52.159:443/test/apache-php:latest",
"imageID": "docker://sha256:2e233ad9329bd7f65572dd6acb1a03e8839c36abfdb1d1f9012d84d13cecf9fc",
"containerID": "docker://f3daa802f753d123fe66b2cba2e917725702f8d446c17541822a68f9d2414c6d"
}
]
}
}
]
}
Status Code
Table 2 describes the status code of this API.
|
Status Code |
Description |
|---|---|
|
200 |
This operation succeeds, and a group of Pod resource objects is returned. |
For the description about error status codes, see Status Code.
Last Article: Replacing the Status of a Specified Pod
Next Article: Listing Pods
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.