Accessing Internet through NAT Gateway

Last updated: 2020-11-11 10:55:15

    Overview

    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.

    Directions

    Checking whether pods can access internet

    1. Log in to the TKE console and click Elastic Cluster in the left sidebar.
    2. On the Elastic Cluster list page, click the ID of the target cluster to go to the management page of the cluster.
    3. Click Remote Login for the target container and run a ping command to check whether its pods can access internet.
      If the returned result is as follows, data packets cannot be received, which indicates that the pods cannot access internet.

    Creating a NAT Gateway

    1. Log in to the Tencent Cloud VPC console and click NAT Gateway in the left sidebar.
    2. On the NAT Gateway page, click +Create.
    3. In the Create NAT Gateway window that appears, create a 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

    4. In the left sidebar, click Route Table to go to the Route Table management page.
    5. On the Route Table management page, click +Create.
    6. In the Create Route Table window that appears, create a route table in the same region and same VPC as the EKS cluster.

      The 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 a NAT Gateway.
    7. 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.

    1. 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.
    2. In the Associate Subnets window that appears, 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.

    Configuration Verification

    1. On the Elastic Cluster list page, click the ID of the target cluster to go to the management page of the cluster.
    2. Click Remote Login for the target container and run a ping command to check whether its pods can access internet.
      If the returned result is as follows, the pods can access internet normally.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help