Skip to content

EKS on VPC using NAT instead of local network

0

I have an EKS Cluster using VPC and a NAT attached to it.

MY route table is like this for this VPC is like this. The pl-63a5400a is a s3 VPC Endpoint Gateway.

Destination | Target | Status | Propagated pl-63a5400a | vpce-067ca03758000b25b | Active | No 0.0.0.0/0 | nat-02d3ddb0fba3edd4f | Active | No 10.59.149.128/25 | local | Active | No 10.77.153.0/24 | local | Active | No 100.64.0.0/16 | local | Active | No 100.65.0.0/16 | local | Active | No 100.66.0.0/16 | local | Active | No

Supposedly all internal traffic when communicating internally should not traffic on NAT gateway. But whenever I try to run a spark application on kubernets I can see a spike on NAT Gateway usage, and so I'm being charged by NAT traffic.

When analyzing VPC Flow Log I can see the ENI of NAT being used for internal communication.

Any advice on that?

2 Answers
0

When you say internal traffic, do you have an IP for example thats going via the NAT gateway which should be LOCAL?

EXPERT

answered 2 years ago

  • When I analyze VPC Log Flow, I can see this.

    eni-0dcb57a8cffee73e8 is the ENI for NAT and 100.64.122.174 is my private EKS VPC

    version account-id interface-id srcaddr dstaddr srcport dstport protocol packets bytes start end action log-status 2 ... eni-0dcb57a8cffee73e8 100.64.122.174 10.77.153.112 56442 443 6 18 3727 1734692989 1734693008 ACCEPT OK 2 ... eni-0dcb57a8cffee73e8 100.64.122.174 10.77.153.112 58172 443 6 22 7150 1734693027 1734693057 ACCEPT OK 2 ... eni-0dcb57a8cffee73e8 100.64.122.174 10.77.153.112 44000 443 6 18 3727 1734693037 1734693062 ACCEPT OK 2 ... eni-0dcb57a8cffee73e8 10.77.153.112 100.64.122.174 443 38070 6 35 21521 1734692945 1734692973 ACCEPT OK 2 ... eni-0dcb57a8cffee73e8 10.77.153.112 100.64.122.174 443 48458 6 33 21441 1734692800 1734692825 ACCEPT OK 2 ... eni-0dcb57a8cffee73e8 10.77.153.112 100.64.122.174 443 41720 6 20 10155 1734692800 1734692825 ACCEPT OK

    If i'm not wrong this should not happen.

  • Can you confirm the route table is associated to the correct Subents?

  • Yep, it is connected to the correct subnets

    rtb-0342d2f06937fc1d7

    vpc-primary-USEA11 - EKS Subnet 2 subnet-0c4d9d7655dd82a0b 100.64.128.0/17 – vpc-primary-USEA11 - EKS Subnet 1 subnet-045a376854b3ddeb8 100.64.0.0/17 –

  • Just create a Flow Log exclusive for this ENI and I can see a lot of calls to AWS us-west-2 ec2 endpoints, is this normal?

0

Based on the information provided, it appears that your EKS cluster is experiencing unexpected NAT Gateway usage for internal communication, which should typically remain within the VPC. Here are some potential reasons and advice to address this issue:

  1. Cluster Endpoint Configuration: Check your EKS cluster's API server endpoint configuration. If only the public endpoint is enabled, Kubernetes API requests originating from within your cluster's VPC will leave the VPC and go through the NAT Gateway. To resolve this, enable both public and private endpoints for your cluster. This allows nodes to communicate with the control plane via private VPC endpoints, keeping traffic within the VPC.

  2. VPC DNS Settings: Ensure that your VPC has enableDnsHostnames and enableDnsSupport set to true, and the DHCP options for your VPC include AmazonProvidedDNS in its domain name servers list. This is necessary for proper routing of traffic to your API server through the private hosted zone created by EKS.

  3. Security Group Configuration: Verify that the control plane security group allows ingress traffic on port 443 from your node security groups. This ensures that nodes can communicate directly with the API server without going through the NAT Gateway.

  4. Networking Add-ons: If you're using alternative networking add-ons or self-managing the default ones (Amazon VPC CNI, CoreDNS, kube-proxy), ensure they are configured correctly to use the cluster's private endpoint.

  5. Application-specific Configuration: Review your Spark application configuration to ensure it's not explicitly using public endpoints for internal communication. Make sure it's configured to use private DNS names or IP addresses for internal services.

  6. VPC Endpoints: Consider setting up VPC endpoints for other AWS services your application might be using (besides the S3 endpoint you already have). This can help reduce traffic going through the NAT Gateway.

  7. Flow Log Analysis: Continue analyzing your VPC Flow Logs to identify the specific sources and destinations of the traffic going through the NAT Gateway. This can help pinpoint which components of your application or cluster are causing the unexpected external communication.

By addressing these points, you should be able to minimize or eliminate unnecessary NAT Gateway usage for internal communication within your EKS cluster.
Sources
VPC and Subnet Considerations - Amazon EKS
Control network access to cluster API server endpoint - Amazon EKS
Amazon EKS introduces cluster creation flexibility for networking add-ons - AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.