更新时间:2022-04-18 GMT+08:00
分享

创建Namespace

功能介绍

该API用于创建一个Namespace。

URI

POST /api/v1/namespaces

表1 描述该API的参数。

表1 参数描述

参数

是否必选

描述

pretty

No

If 'true', then the output is pretty printed.

请求消息

请求参数:

请求参数如表2所示。

表2 参数描述

参数

是否必选

参数类型

描述

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

metadata object

-

spec

No

spec object

-

status

No

status object

-

表3 spec字段数据结构说明

参数

是否必选

参数类型

描述

finalizers

No

Array of strings

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

表4 status字段数据结构说明

参数

是否必选

参数类型

描述

phase

No

String

Phase is the current lifecycle phase of the namespace.

请求示例:

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

响应消息

响应参数:

响应参数的详细描述请参见请求消息

响应示例:

{ 
   "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" 
   } 
 }

状态码

表5描述API的状态码。

表5 状态码

状态码

描述

201

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

异常状态码请参见状态码

分享:

    相关文档

    相关产品

close