• Cloud Container Engine

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

Creating a Namespace

Function

This API is used to create a Namespace.

URI

POST /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.

Request

Request parameters:

Table 2 describes the request parameters.

Table 2 Parameter description

Parameter

Mandatory

Type

Description

kind

Yes

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.

The value of this parameter is Namespace.

apiVersion

Yes

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.

The value of this parameter is v1.

metadata

Yes

Table 11

-

spec

No

Table 3

-

status

No

Table 4

-

Table 3 Data structure of the spec field

Parameter

Mandatory

Type

Description

finalizers

No

Array[String]

Finalizers is an opaque list of values that must be empty to permanently remove object from storage.

Table 4 Data structure of the status field

Parameter

Mandatory

Type

Description

phase

No

String

Phase is the current lifecycle phase of the namespace.

Example request:

{ 
   "apiVersion":"v1", 
   "kind": "Namespace", 
   "metadata": { 
     "name": "development", 
     "labels": { 
       "name": "development" 
     } 
   }, 
   "spec": { 
     "finalizers": ["kubernetes"] 
   }, 
   "status": { 
     "phase": "Active" 
   } 
 }

Response

Response parameters:

For the description about response parameters, see the parameter description in Request.

Example response:

{ 
   "kind": "Namespace", 
   "apiVersion": "v1", 
   "metadata": { 
     "name": "development", 
     "selfLink": "/api/v1/namespaces/development", 
     "uid": "c98a9a98-595c-11e6-b444-286ed488fafe", 
     "resourceVersion": "16578", 
   "creationTimestamp": "2016-08-03T09:29:33Z", 
     "labels": { 
       "name": "development" 
     } 
   }, 
   "spec": { 
     "finalizers": [ 
       "kubernetes" 
     ] 
   }, 
   "status": { 
     "phase": "Active" 
   } 
 }

Status Code

Table 5 describes the status code of this API.

Table 5 Status code

Status Code

Description

201

This operation succeeds, and a Namespace resource object is returned.

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