功能介绍
创建一个Network对象。
Network对象是华为云CCI新增对象,用于定义kubernetes中一个namespace内的网络。目前CCI支持VPC网络,一个VPC网络类型的network对象对应于华为云 虚拟私有云 服务中的一个子网。
CCI的容器网络依赖于华为云底层VPC网络,因此在创建network对象前,需要先调用虚拟 私有云 的接口创建或者查询已有子网信息。
须知: 此处VPC和子网的网段不能为10.247.0.0/16,10.247.0.0/16是 云容器实例 预留给Service的网段。如果您使用此网段,后续可能会造成IP冲突,导致负载无法创建或服务不可用;如果您不需要通过Service访问,而是直接访问Pod,则可以使用此网段。
具体如何创建一个Network对象,可以参考Namespace和Network
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
URI
POST /apis/networking.cci.io/v1beta1/namespaces/{namespace}/networks
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
namespace |
是 |
String |
object name and auth scope, such as for teams and projects |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
dryRun |
否 |
String |
When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed |
fieldManager |
否 |
String |
fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. |
pretty |
否 |
String |
If 'true', then the output is pretty printed. |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token。 通过调用 IAM 服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
Content-Type |
是 |
String |
消息体的类型(格式),默认取值为“application/json” 缺省值:application/json |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
metadata |
否 |
ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create. |
|
spec |
否 |
Spec defines the attributes on a network |
|
status |
否 |
Status describes the network status |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
apiVersion |
否 |
String |
APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted. |
fieldsType |
否 |
String |
FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1" |
fieldsV1 |
否 |
Object |
FieldsV1 holds the first JSON version format as described in the "FieldsV1" type. |
manager |
否 |
String |
Manager is an identifier of the workflow managing these fields. |
operation |
否 |
String |
Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'. |
time |
否 |
String |
Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply' |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
apiVersion |
是 |
String |
API version of the referent. |
blockOwnerDeletion |
否 |
Boolean |
If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned. |
controller |
否 |
Boolean |
If true, this reference points to the managing controller. |
kind |
是 |
String |
Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
name |
是 |
String |
Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names |
uid |
是 |
String |
UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
attachedVPC |
否 |
String |
ID of the VPC to attach |
availableZone |
否 |
String |
available zone |
cidr |
否 |
String |
The CIDR of the network |
networkID |
否 |
String |
network ID |
networkType |
否 |
String |
network type like 'overlay_l2' |
subnetID |
否 |
String |
Subnet ID |
subnets |
否 |
Subnets |
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
metadata |
ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create. |
|
spec |
Spec defines the attributes on a network |
|
status |
Status describes the network status |
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted. |
fieldsType |
String |
FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1" |
fieldsV1 |
Object |
FieldsV1 holds the first JSON version format as described in the "FieldsV1" type. |
manager |
String |
Manager is an identifier of the workflow managing these fields. |
operation |
String |
Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'. |
time |
String |
Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply' |
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
API version of the referent. |
blockOwnerDeletion |
Boolean |
If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned. |
controller |
Boolean |
If true, this reference points to the managing controller. |
kind |
String |
Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
name |
String |
Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names |
uid |
String |
UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids |
参数 |
参数类型 |
描述 |
---|---|---|
attachedVPC |
String |
ID of the VPC to attach |
availableZone |
String |
available zone |
cidr |
String |
The CIDR of the network |
networkID |
String |
network ID |
networkType |
String |
network type like 'overlay_l2' |
subnetID |
String |
Subnet ID |
subnets |
Subnets |
参数 |
参数类型 |
描述 |
---|---|---|
cidr |
String |
The CIDR of the network |
networkID |
String |
NetworkID describes the subnet network id |
subnetID |
String |
SubnetID describes the subnet id |
参数 |
参数类型 |
描述 |
---|---|---|
message |
String |
Message describes why network is in current state |
state |
String |
State describes the network state |
状态码: 201
参数 |
参数类型 |
描述 |
---|---|---|
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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
metadata |
ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create. |
|
spec |
Spec defines the attributes on a network |
|
status |
Status describes the network status |
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted. |
fieldsType |
String |
FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1" |
fieldsV1 |
Object |
FieldsV1 holds the first JSON version format as described in the "FieldsV1" type. |
manager |
String |
Manager is an identifier of the workflow managing these fields. |
operation |
String |
Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'. |
time |
String |
Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply' |
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
API version of the referent. |
blockOwnerDeletion |
Boolean |
If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned. |
controller |
Boolean |
If true, this reference points to the managing controller. |
kind |
String |
Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
name |
String |
Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names |
uid |
String |
UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids |
参数 |
参数类型 |
描述 |
---|---|---|
attachedVPC |
String |
ID of the VPC to attach |
availableZone |
String |
available zone |
cidr |
String |
The CIDR of the network |
networkID |
String |
network ID |
networkType |
String |
network type like 'overlay_l2' |
subnetID |
String |
Subnet ID |
subnets |
Subnets |
参数 |
参数类型 |
描述 |
---|---|---|
cidr |
String |
The CIDR of the network |
networkID |
String |
NetworkID describes the subnet network id |
subnetID |
String |
SubnetID describes the subnet id |
参数 |
参数类型 |
描述 |
---|---|---|
message |
String |
Message describes why network is in current state |
state |
String |
State describes the network state |
状态码: 202
参数 |
参数类型 |
描述 |
---|---|---|
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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources |
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. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
metadata |
ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create. |
|
spec |
Spec defines the attributes on a network |
|
status |
Status describes the network status |
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted. |
fieldsType |
String |
FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1" |
fieldsV1 |
Object |
FieldsV1 holds the first JSON version format as described in the "FieldsV1" type. |
manager |
String |
Manager is an identifier of the workflow managing these fields. |
operation |
String |
Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'. |
time |
String |
Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply' |
参数 |
参数类型 |
描述 |
---|---|---|
apiVersion |
String |
API version of the referent. |
blockOwnerDeletion |
Boolean |
If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned. |
controller |
Boolean |
If true, this reference points to the managing controller. |
kind |
String |
Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
name |
String |
Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names |
uid |
String |
UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids |
参数 |
参数类型 |
描述 |
---|---|---|
attachedVPC |
String |
ID of the VPC to attach |
availableZone |
String |
available zone |
cidr |
String |
The CIDR of the network |
networkID |
String |
network ID |
networkType |
String |
network type like 'overlay_l2' |
subnetID |
String |
Subnet ID |
subnets |
Subnets |
请求示例
创建Network,指定账号ID、项目ID和安全组ID,关联VPC和子网网段。 metadata.annotations必选字段数据结构说明
参数 | 是否必选 | 参数类型 | 描述 |
---|---|---|---|
network.alpha.kubernetes.io/default-security-group | Yes | String | Network对应子网所属安全组ID。 |
network.alpha.kubernetes.io/project-id | Yes | String | Network所属用户的project-id,获取方法请参见获取项目ID。 |
network.alpha.kubernetes.io/domain-id | Yes | String | Network所属用户的domain-id,获取方法请参见获取帐号ID。 |
VPC网络类型
参数 | 是否必选 | 参数类型 | 描述 |
---|---|---|---|
cidr | No | String | Network对应VPC子网的网段。**说明:**此处VPC和子网的网段不能为10.247.0.0/16,10.247.0.0/16是 云容器 实例预留给Service的网段。如果您使用此网段,后续可能会造成IP冲突,导致负载无法创建或服务不可用;如果您不需要通过Service访问,而是直接访问Pod,则可以使用此网段。 |
attachedVPC | Yes | String | Network所在VPC的ID。 |
networkType | Yes | String | Network网络类型,VPC网络类型取值:underlay_neutron。 |
networkID | Yes | String | Network对应VPC子网的网络ID。 |
subnetID | Yes | String | Network对应VPC子网的子网ID。 |
availableZone | Yes | String | Network对应VPC子网所在可用区。当前支持“华北-北京四”、“华东-上海一”、“华东-上海二”和“华南-广州”区域,该值可设置为、“cn-north-4a”、“cn-east-3a”、“cn-east-2d”或“cn-south-1f”。 |
{
"apiVersion" : "networking.cci.io/v1beta1",
"kind" : "Network",
"metadata" : {
"annotations" : {
"network.alpha.kubernetes.io/default-security-group" : "security-group-id",
"network.alpha.kubernetes.io/domain-id" : "domain-id",
"network.alpha.kubernetes.io/project-id" : "project-id"
},
"name" : "test-network",
"namespace" : "test-ns"
},
"spec" : {
"attachedVPC" : "vpc-id",
"availableZone" : "cn-north-4a",
"cidr" : "192.168.0.0/24",
"networkID" : "network-id",
"networkType" : "underlay_neutron",
"subnetID" : "subnet-id"
}
}
响应示例
状态码: 200
OK
{
"apiVersion" : "networking.cci.io/v1beta1",
"kind" : "Network",
"metadata" : {
"annotations" : {
"network.alpha.kubernetes.io/default-security-group" : "security-group-id",
"network.alpha.kubernetes.io/domain-id" : "domain-id",
"network.alpha.kubernetes.io/project-id" : "project-id",
"network.alpha.kubernetes.io/type" : "underlay_neutron"
},
"creationTimestamp" : "2018-08-21T02:35:59Z",
"name" : "test-network",
"namespace" : "test-ns",
"resourceVersion" : "2025736",
"selfLink" : "/apis/networking.cci.io/v1beta1/namespaces/test-ns/networks/test-network",
"uid" : "f03452ac-a4ea-11e8-8500-c81fbe371a17"
},
"spec" : {
"attachedVPC" : "vpc-id",
"availableZone" : "cn-north-4a",
"cidr" : "192.168.0.0/24",
"networkID" : "network-id",
"networkType" : "underlay_neutron",
"subnetID" : "subnet-id"
},
"status" : {
"state" : "Initializing"
}
}
状态码
状态码 |
描述 |
---|---|
200 |
OK |
201 |
Created |
202 |
Accepted |
400 |
BadRequest |
401 |
Unauthorized |
403 |
Forbidden |
404 |
NotFound |
405 |
MethodNotAllowed |
406 |
NotAcceptable |
409 |
AlreadyExists |
415 |
UnsupportedMediaType |
422 |
Invalid |
429 |
TooManyRequests |
500 |
InternalError |
503 |
ServiceUnavailable |
504 |
ServerTimeout |