This document describes how to set a static IP address for external access if the cluster needs to actively access external devices.
Check whether the following requirements are met in the cluster of your scaling group:
If yes, you can set the IP address by referring to the following solution.
See the following figure:
Select a region in the drop-down list above the list and click New to create a VPC instance. For example, select the "North China (Beijing)" region.
Enter the names of the VPC, subnet, and CIDR block, and select an availability zone for the subnet.
Log in to the [Tencent Cloud console] (https://console.cloud.tencent.com/), click "Virtual Private Cloud" in the navigation bar, and then click "Subnet" in the leftside bar. Select a region and VPC in the drop-down list.
Click New, complete the subnet name, CIDR block, availability zone, and associated route table. Then, click Create.
After finishing the creation, you can purchase CVMs for this subnet.
Log in to the Tencent Cloud console, click the "Virtual Private Cloud" tab, and select "NAT Gateway".
Click Create in the upper-left corner, and complete or confirm the following parameters in the pop-up box:
Click OK to finish creating the NAT gateway.
After finishing the creation, configure routing rules on the route table page in the VPC console to direct subnet traffic to the NAT gateway.
In the route table list, click the route table ID associated with the subnet that needs to access the Internet to go to the details page of the route table. Then, click Edit in "Routing Policies".
Click "New Line", specify the destination (for example, enter "0.0.0.0/0" in this example), select "NAT Gateway" as the next-hop type, select the ID of the created NAT gateway, and then click OK.
Now, even without a public IP address, your CVMs in this subnet can actively access external devices through the static IP address of the NAT gateway, during which this IP address is externally static.
Even if you purchase a CVM without any public IP addresses and with zero bandwidth, you can still actively access external devices, as shown in the following figure:
However, the scaling group needs to recognize this subnet and ensure that all the CVMs are created in this subnet.
This step is to map the subnet information to the scaling group so that the newly expanded CVM can be installed in this subnet by the scaling group.
In this way, the expanded CVM will use the static outbound IP address of the NAT gateway to access external devices.
In the Auto Scaling console, click Create:
See the following figure:
You have finished the configuration.