Elastic Kubernetes Service (EKS) allows you to enable services in a cluster to access internet by configuring the NAT Gateway and route table. This document guides you through the configuration.
Creating an NAT gateway
- Log in to the Tencent Cloud VPC console and click NAT Gateway on the left sidebar.
- On the NAT Gateway page, click +Create.
- In the pop-up Create NAT Gateway window, create an NAT gateway in the same region and same VPC as the EKS cluster. For more information, see Getting Started.
Creating a route table for the NAT gateway
- On the left sidebar, click Route Table to go to the Route Table management page.
- On the Route Table management page, click +Create.
- In the pop-up Create Route Table window, create a route table in the same region and same VPC as the EKS cluster, as shown in the figure below:
Main parameters are described as follows:
- Destination: select the public IP address to be accessed. You can configure a CIDR block for this parameter. For example, if you enter
0.0.0.0/0, all traffic will be forwarded to the NAT gateway.
- Next Hop Type: select NAT Gateway.
- Next Hop: select the NAT gateway created in Creating an NAT Gateway.
- Click Create.
Associating subnets with the route table
After configuring routes, you need to select subnets and associate them with the route table. Then, traffic from the selected subnets to internet will be routed to the NAT gateway.
- On the Route Table page, find the route table created in the Creating a route table for the NAT gateway step and click Associate Subnets on the right.
- In the pop-up Associate Subnets window, select the subnets to be associated and click OK.
After associating the route table with the subnets, resources in the same VPC can access internet through the public IP address of the NAT gateway.
This subnet is not a Service CIDR block but a container network.
- On the Elastic Cluster list page, click the ID of the target cluster to go to the management page of the cluster.
- Click Remote Login for the target container and run a ping command to check whether its pods can access internet. If the results in the figure below are returned, it means the pods have successfully accessed the internet.