Some workloads require a fixed IP address. This topic describes how to specify a private IP address for an ECI instance when you create it.
How it works
By default, when you create an ECI instance, the system randomly assigns a private IP address from the CIDR block of the configured vSwitch. In some scenarios, you may want to specify a private IP address for the instance. For example, during a service migration, you can delete an old ECI instance and then assign its IP address to the new instance to ensure service continuity.
Limits
The private IP addresses that you specified for pods must be IPv4 addresses.
Configuration
To specify a private IP address for an ECI instance, use the PrivateIpAddress parameter when calling the CreateContainerGroup API operation. The following table describes the related parameters. For more information, see CreateContainerGroup.
|
Parameter |
Type |
Example |
Description |
|
VSwitchId |
string |
vsw-bp1gds63lmlm7ib05**** |
The vSwitch to which the instance belongs. When you specify a private IP address, you must also specify a vSwitch. |
|
SecurityGroupId |
string |
sg-bp1daxpbz9lzpvvc**** |
The security group to which the instance belongs. If you specify a vSwitch, you must also specify a security group. |
|
PrivateIpAddress |
string |
172.16.0.1 |
An available private IP address from the vSwitch's CIDR block. |
Example
-
Create an ECI instance with a specified private IP address.
The following code shows example parameters for calling the CreateContainerGroup API operation:
{ "RegionId": "cn-beijing", "SecurityGroupId": "sg-2ze1pjtsbqcuykpp****", "VSwitchId": "vsw-2ze94pjtfuj9vaymf****", "PrivateIpAddress": "172.16.0.1", "ContainerGroupName": "test", "Container": [ { "Name": "nginx", "Image": "registry-vpc.cn-beijing.aliyuncs.com/eci_open/nginx:1.14.2" } ] } -
Verify the private IP address of the instance.
You can either call the DescribeContainerGroups API operation with the returned instance ID to find the private IP address in the IntranetIp response field, or view it in the console.
In the ECI instance list, the IP Address column shows the instance's assigned private IP address, such as
172.16.0.1.