Creating a Network
Function
This API is used to create a network.
Network is a new object in CCI that defines the mapping relationship between a network of a namespace in Kubernetes, and a VPC and subnet. A network corresponds to a subnet in a VPC.
The container network of CCI depends on the bottom-layer VPC network. Before creating a network, you need to call the VPC API to create a subnet or query existing subnets.
The CIDR blocks of the VPC and subnet cannot be 10.247.0.0/16, which is the CIDR block reserved by CCI for services. If you use this CIDR block, IP address conflicts may occur, which may result in workload creation failures or service unavailability. If you do not need to access pods through services, you can allocate this CIDR block to a VPC.
URI
POST /apis/networking.cci.io/v1beta1/namespaces/{namespace}/networks
|
Parameter |
Description |
|---|---|
|
namespace |
Object name and auth scope, such as for teams and projects. |
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
pretty |
No |
If 'true', then the output is pretty printed. |
Request
Request parameters
|
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. The value of this parameter is Network. |
|
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 networking.cci.io. |
|
metadata |
Yes |
Standard object metadata. For details about the annotations field, see Table 4. The value of metadata.Namespace must be set to the namespace being operated. |
|
|
spec |
Yes |
Specification of the desired behavior of the Network. |
|
|
status |
No |
Most recently observed status of the Network. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
network.alpha.kubernetes.io/default-security-group |
Yes |
String |
ID of the security group to which the subnet of the network belongs. |
|
network.alpha.kubernetes.io/project-id |
Yes |
String |
Project ID of the tenant that creates the network. To obtain the project ID, see Obtaining a Project ID. |
|
network.alpha.kubernetes.io/domain-id |
Yes |
String |
Domain ID of the tenant that creates the network. To obtain the project ID, see Obtaining an Account ID. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
cidr |
No |
String |
Network segment of the VPC subnet to which the network belongs.
NOTE:
The CIDR blocks of the VPC and subnet cannot be 10.247.0.0/16, which is the CIDR block reserved by CCI for services. If you use this CIDR block, IP address conflicts may occur, which may result in workload creation failures or service unavailability. If you do not need to access pods through services, you can allocate this CIDR block to a VPC. |
|
attachedVPC |
Yes |
String |
ID of the VPC to which the network belongs. |
|
networkType |
Yes |
String |
Network type. Currently, only the underlay_neutron network type is supported. |
|
networkID |
Yes |
String |
Network ID of the VPC subnet in which the network belongs. |
|
subnetID |
Yes |
String |
ID of the VPC subnet to which the network belongs. |
|
availableZone |
Yes |
String |
AZ to which the VPC subnet of the network belongs. Currently, the following regions are supported: CN North-Beijing 1, CN North-Beijing 4, and CN East-Shanghai 1. You can set this parameter to cn-north-1a, cn-north-4a, or cn-east-3a. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
state |
No |
String |
Network status, which can be Initializing, Active, Pending, Failed, or Terminating. |
|
Message |
No |
String |
Reason why the network is in the current state. |
{
"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": {
"availableZone": "cn-north-1a",
"cidr": "192.168.0.0/24",
"attachedVPC": "vpc-id",
"networkID": "network-id",
"networkType": "underlay_neutron",
"subnetID": "subnet-id"
}
}
Response
Response parameters
For the description about response parameters, see Table 3.
Example response
{
"kind": "Network",
"apiVersion": "networking.cci.io/v1beta1",
"metadata": {
"name": "test-network",
"namespace": "test-ns",
"selfLink": "/apis/networking.cci.io/v1beta1/namespaces/test-ns/networks/test-network",
"uid": "f03452ac-a4ea-11e8-8500-c81fbe371a17",
"resourceVersion": "2025736",
"creationTimestamp": "2018-08-21T02:35:59Z",
"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"
},
"enable": true
},
"spec": {
"availableZone": "cn-north-1a",
"cidr": "192.168.0.0/24",
"attachedVPC": "vpc-id",
"networkID": "network-id",
"networkType": "underlay_neutron",
"subnetID": "subnet-id"
},
"status": {
"state": "Initializing"
}
}
Status Code
|
Status Code |
Description |
|---|---|
|
201 |
This operation succeeds, and a Network resource object is returned. |
For more status codes, see Status Codes.
Last Article: Network
Next Article: Reading a Network
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.