Help & DocumentationAuto ScalingBest PracticesSetting Static Outbound IP for Scaling Group

Setting Static Outbound IP for Scaling Group

Last updated: 2020-02-25 15:28:18

PDF

In this section, we will introduce to you about how to set up a fixed IP address for external access if the cluster requires to actively make external access.

Required Conditions

If three conditions are satisfied in the cluster of your scaling group at the same time as follows:
Requests are received from CLB;
Cluster machines need to actively make external access;
When making external access, it is desired to use a Fixed Public IP.

The IP address can be set up according to the following solution.

Solution Overview

  1. Receive and respond to external requests via CLB.
  2. Place the machine in the subnet of VPC, direct the routing table to the NAT gateway and all active external request are delivered via the public IP of the NAT gateway.
  3. The network attribute of the scaling group is set as this subnet, so that all the expanded machines will actively make external access via the NAT gateway.

See the figure below:

Setting Method

Step 1: create VPC and subnet

1. Create a VPC

  1. Log in to Tencent Cloud Console , click Virtual Private Cloud In the navigation bar, or click Experience In Tencent Cloud's VPC Overview Page To enter the VPC Console .

  2. Choose a region in the drop-down box above the list and click New To create a VPC. For example, choose the region of "North China (Beijing)".

  3. Enter names of the VPC and subnet as well as CIDR, and select the availability zone for the subnet.

  4. Click [create].

2. Create a subnet

  1. Log in to [ Tencent Cloud Console] (https://console.cloud.tencent.com/), click "Virtual Private Cloud" in the navigation bar, and then click "Subnet" in the left navigation bar. Choose a region and VPC in the drop-down box.

  2. Click [Create], and fill in the subnetwork name, CIDR, availability zone and Associate Route table. Then click [create] to confirm.

  3. After the creation is completed, you can purchase machines for this subnet.

Step 2: Create a NAT gateway

1. Purchase desired products

  1. Log in to Tencent Cloud Console , select "Virtual Private Cloud" tab, and then select "NAT Gateway".

  2. Click New At the upper left corner, and enter or confirm the following parameters in the pop-up box:

    • Gateway Name.
    • Gateway type (which can be modified after creation)
    • VPC of the NAT Gateway service (which was just created by you)
    • Assign the elastic IP for the NAT gateway. This IP is the fixed IP via which your machine makes external access.
  3. After selection, click OK To complete the creation of NAT gateway.

  4. After the creation of the NAT gateway is completed, you need to configure the routing rules on the Routing Table page of the VPC Console to direct the subnet traffic to the NAT gateway.

2. Set the routing table (highlights)

  1. Log in to Tencent Cloud Console , click "Virtual Private Cloud" in the navigation bar to enter the Virtual Private Cloud Console , and then select "Routing Table".

  2. In the routing table list, click the routing table ID associated with the subnet that needs to access the Internet to enter the details page of the routing table, and then click "Edit" button in "Routing Policies".

  3. Click "New Line" to fill in the destination (for example, "0.0.0.0Zero" can be entered in this scenario), select "NAT Gateway" as the next hop type, select the created NAT gateway ID, and then click "OK".

Now, even without public IP, your machine in this subnet can actively get external access via the fixed IP of the NAT gateway, during which this IP is shown to be fixed externally.

Even if I purchase a CVM Server without any public IP and with the bandwidth of zero, I still can actively make external access, which is shown as follows:

However, the scaling group needs to identify this subnet and ensure that all the machines are created on this subnet.

Step 3: Set up the scaling group

It is used to direct the subnet information to the scaling group so that the newly expanded machine can be installed in this subnet by the scaling group.
In this way, the expanded machine will use the fixed exit IP address of the NAT gateway to access external websites.

Log in to the AS console And click Launch Configuration From the left sidebar.

Fill in the name of the scaling group, launch configuration (to be set up well in advance), maximum group size, minimum group size, initial number of instances, and other information.
Select "Network" and "Subnet", and then direct them to the selected VPC and subnet (important) .

See the figure below:

The setting has been completed.