IDC

创建Namespace_云容器实例 CCI_API参考_Kubernetes API_Namespac

作者:admin 2021-09-24 我要评论

功能介绍 创建一个Namespace。 当前云容器实例提供 “通用计算型” 和 “GPU加速型” 两种类型的资源,创建命名空间时需要选择资源类型,后续创建的负载中容器就...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

功能介绍

创建一个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

表1 Query描述

参数

是否必选

描述

pretty

No

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

请求消息

请求参数:

表2 Namespace v1数据结构说明

参数

是否必选

参数类型

描述

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

其中,annotations、labels字段请参见表3表4

spec

No

Object

Spec defines the behavior of the Namespace. 详情请参见表5

status

No

Object

Status describes the current status of a Namespace. 详情请参见表7

表3 metadata.annotations字段说明

参数

是否必选

参数类型

描述

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按需实例。

表4 metadata.labels字段说明

参数

是否必选

参数类型

描述

sys_enterprise_project_id

No

String

用于指定企业项目的ID。

表5 namespace spec字段数据结构说明

参数

是否必选

参数类型

描述

finalizers

No

Array of objects

Finalizers is an opaque list of values that must be empty to permanently remove object from storage. 详情请参见表6

表6 FinalizerName取值说明

名称

FinalizerKubernetes

kubernetes

表7 namespace status字段数据结构说明

参数

是否必选

参数类型

描述

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

表8 metadata.annotations字段说明

参数

参数类型

描述

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

状态码

表9描述API的状态码。

表9 状态码

状态码

描述

201

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

更多状态码请参见状态码

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
腾讯云代理商
精彩导读
海外云服务器
热门资讯
腾讯云代理商