• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference 2.0
  4. Kubernetes API
  5. Namespace
  6. Listing Namespaces

Listing Namespaces

Function

This API is used to read the details about all Namespaces in a cluster.

URI

GET /api/v1/namespaces

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

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.

Request

N/A

Response

Response parameters:

Table 2 describes the response parameters.

Table 2 Parameter description

Parameter

Type

Description

kind

String

Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase.

apiVersion

String

APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values.

metadata

Table 3

-

items

Request

Items is the list of Namespace objects in the list.

Table 3 Data structure of the metadata field

Parameter

Type

Description

selfLink

String

SelfLink is a URL representing this object. Populated by the system. Read-only.

resourceVersion

String

String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only.

Example response:

{
    "kind": "NamespaceList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces",
        "resourceVersion": "594181"
    },
    "items": [
        {
            "metadata": {
                "name": "default",
                "selfLink": "/api/v1/namespaces/default",
                "uid": "90dd5244-5881-11e7-b5d7-fa163e08a2fd",
                "resourceVersion": "6",
                "creationTimestamp": "2017-06-24T02:05:16Z"
            },
            "spec": {
                "finalizers": [
                    "kubernetes"
                ]
            },
            "status": {
                "phase": "Active"
            }
        },
        {
            "metadata": {
                "name": "kube-system",
                "selfLink": "/api/v1/namespaceskube-system",
                "uid": "9178fce6-5881-11e7-b5d7-fa163e08a2fd",
                "resourceVersion": "25",
                "creationTimestamp": "2017-06-24T02:05:17Z"
            },
            "spec": {
                "finalizers": [
                    "kubernetes"
                ]
            },
            "status": {
                "phase": "Active"
            }
        }
    ]
}

Status Code

Table 4 describes the status code of this API.

Table 4 Status code

Status Code

Description

200

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

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