Accessing Public Networks from a Container
You can use NAT Gateway to enable containers in a VPC to access public networks. NAT Gateway provides source network address translation (SNAT), which translates private IP addresses to a public IP address by binding an EIP to the NAT gateway, providing secure and efficient access to the Internet. Figure 1 shows the SNAT architecture. The SNAT function allows the pods in a VPC to access the Internet without being bound to an EIP. SNAT supports a large number of concurrent connections, which makes it suitable for applications involving a large number of requests and connections.
To enable pods to access the Internet, perform the following steps:
- Buy an EIP.
- Log in to the management console.
- Click in the upper left corner to select the desired region and project.
- Choose Service List > Networking > Virtual Private Cloud.
- In the navigation pane, choose Elastic IP and Bandwidth > EIPs.
- On the EIPs page, click Buy EIP.
- Set the parameters.
Set Region to the region where pods are located.
Figure 2 Buying an EIP
- Buy a NAT gateway. For details, see Buy a Public NAT Gateway.
- Log in to the management console.
- Click in the upper left corner to select the desired region and project.
- Choose Service List > Networking > NAT Gateway.
- On the displayed page, click Buy NAT Gateway.
- Set the parameters.
Select the VPC and subnet that you have configured for the namespace where the pods are located.
Figure 3 Buying a NAT gateway
- Configure an SNAT rule and bind the EIP to the subnet. For details, see Add an SNAT Rule.
- Log in to the management console.
- Click in the upper left corner to select the desired region and project.
- Choose Service List > Networking > NAT Gateway.
- On the displayed page, click the name of the NAT gateway for which you want to add the SNAT rule.
- On the SNAT Rules tab page, click Add SNAT Rule.
- Set the parameters.
Select the subnet that you have configured for the namespace where the pods are located.
Figure 4 Adding an SNAT rule
After the SNAT rule is configured, public networks can be accessed from the container.
Figure 5 Accessing public networks from a container
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot