功能介绍
创建一个Namespace。
当前云容器实例提供“通用计算型”和“GPU加速型”两种类型的资源,创建命名空间时需要选择资源类型,后续创建的负载中容器就运行在此类型的集群上。调用接口时必须指定metadata.annotations中namespace.kubernetes.io/flavor字段为如下值。
- general-computing:通用计算型,基本水平的计算、存储和网络资源,适用于通用工作负载场景。
- gpu-accelerated:GPU加速型,突出的图形计算能力,适用于AI等高性能场景。
Namespace下必须要创建一个Network,用于定义kubernetes中一个namespace内的网络与华为云虚拟私有云服务的子网和vpc的映射关系,具体请参见创建Network。
URI
POST /api/v1/namespaces
参数 |
是否必选 |
描述 |
---|---|---|
pretty |
No |
If 'true', then the output is pretty printed. |
请求消息
请求参数:
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
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 |
Object |
Standard object metadata. 详情请参见表10。 |
spec |
No |
Object |
Spec defines the behavior of the Namespace. 详情请参见表5。 |
status |
No |
Object |
Status describes the current status of a Namespace. 详情请参见表7。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
namespace.kubernetes.io/flavor |
Yes |
String |
用于指定namespace所属集群的flavor类型,目前支持GPU加速型(gpu-accelerated)、通用计算型(general-computing)两种类型。 |
namespace.kubernetes.io/allowed-on-shared-node |
No |
String |
用于指定是否开启弹性调度,可设置为true或false。默认取值为false,不开启时不需要指定该参数值。 弹性调度:指当专属资源用尽时,可自动弹性创建CCI按需实例。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
finalizers |
No |
Array of objects |
Finalizers is an opaque list of values that must be empty to permanently remove object from storage. 详情请参见表6。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
phase |
No |
String |
Phase is the current lifecycle phase of the namespace. Namespace的状态有2个: - Active: means the namespace is available for use in the system - Terminating: means the namespace is undergoing graceful termination |
{ "apiVersion": "v1", "kind": "Namespace", "metadata": { "name": "namespace-test", "annotations": { "namespace.kubernetes.io/flavor": "gpu-accelerated" }, "labels": { "sys_enterprise_project_id": "0503dda897000fed2f78c00909158a4d" }, "spec": { "finalizers": [ "kubernetes" ] } } }
响应消息
响应参数:
响应参数的详细描述请参见表2。
参数 |
参数类型 |
描述 |
---|---|---|
pv.kubernetes.io/enable-dynamic-provisioning |
String |
是否支持动态创建存储。 |
tenant.kubernetes.io/domain-id |
String |
用户的帐号ID。 |
tenant.kubernetes.io/domain-name |
String |
用户的帐号名。 |
tenant.kubernetes.io/project-id |
String |
用户的项目ID。 |
tenant.kubernetes.io/project-name |
String |
用户的项目名称。 |
响应示例:
{ "metadata": { "name": "namespace-test", "selfLink": "/api/v1/namespaces/namespace-test", "uid": "68a68c5a-af6b-11e8-8f17-c81fbe371a17", "resourceVersion": "5016746", "creationTimestamp": "2018-09-03T11:20:48Z", "annotations": { "namespace.kubernetes.io/flavor": "gpu-accelerated", "pv.kubernetes.io/enable-dynamic-provisioning": "true", "tenant.kubernetes.io/domain-id": "aadb43c0b14c4cafbccfff483d075987", "tenant.kubernetes.io/domain-name": "cci", "tenant.kubernetes.io/project-id": "51bf52609f2a49c68bfda3398817b376", "tenant.kubernetes.io/project-name": "southchina" }, "enable": true, "labels": { "sys_enterprise_project_id": "0503dda897000fed2f78c00909158a4d" } }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "phase": "Active" } }