• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. Pod (Native Kubernetes APIs)
  5. Listing or Watching Objects of Kind Pod in a Specified Namespace

Listing or Watching Objects of Kind Pod in a Specified Namespace

Function

This API is used to list all Pod resource objects under a specified Namespace.

URI

GET /api/v1/namespaces/{namespace}/pods

Table 1 describes the parameters of this API.

Table 1 Parameter description

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

(A newly added parameter in Kubernetes 1.7)

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/tianxia52/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.18.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/tianxia52/apache-php:latest",
                        "imageID": "docker://sha256:2e233ad9329bd7f65572dd6acb1a03e8839c36abfdb1d1f9012d84d13cecf9fc",
                        "containerID": "docker://f3daa802f753d123fe66b2cba2e917725702f8d446c17541822a68f9d2414c6d"
                    }
                ]
            }
        }
    ]
}

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

200

This operation succeeds, and a group of Pod resource objects is returned.

For the description about status codes, see section Status Codes.