awsdocs / amazon-eks-user-guide

The open source version of the Amazon EKS user guide. You can submit feedback & requests for changes by submitting issues in this repo or by making proposed changes & submitting a pull request.
Other
404 stars 637 forks source link

Possible incorrect statement for pods internet access in external-snat docs #794

Open hendryanw opened 1 month ago

hendryanw commented 1 month ago

Hi team,

The external snat documentation mentioned the following: (Quoted 1 point for brevity)

Due to this behavior:

  • Your Pods can communicate with internet resources only if the node that they're running on has a public or elastic IP address assigned to it and is in a public subnet. A public subnet's associated route table has a route to an internet gateway. We recommend deploying nodes to private subnets, whenever possible.

However, in my experience this is not fully correct. I am running EKS 1.28 with VPC CNI plugin at v1.15.1. Correct me if I'm wrong:

Pod which is deployed on node running on private subnet (without public IP address) can still communicate with resources on the internet via NAT Gateway, even when AWS_VPC_K8S_CNI_EXTERNALSNAT is set to false (default). What happen is:

  1. Pod private IP is translated to node primary private IP of primary ENI
  2. The traffic is routed to NAT Gateway.
  3. NAT Gateway will then translate the node primary private IP into NAT Gateway private IP, and then into NAT Gateway public IP routed via Internet Gateway

I believe, it is best to rephrase the statement in the doc into what AWS recommends in terms of AWS_VPC_K8S_CNI_EXTERNALSNAT configurations to enable outbound internet access for pods as per docs title. For example:

  1. AWS_VPC_K8S_CNI_EXTERNALSNAT is set to false by default to allows pods deployed on nodes running in public subnet to be able to access the internet. If the nodes are deployed on public subnets, the recommendations is to set AWS_VPC_K8S_CNI_EXTERNALSNAT to false.
  2. If the nodes are deployed on private subnets with route to internet via NAT Gateway, the recommendations is to set AWS_VPC_K8S_CNI_EXTERNALSNAT to true.

Thank you.

fincd-aws commented 1 month ago

Hi, thanks!

Maybe I should split this page into two parts: SNAT for public subnets, SNAT for private subnets?

The main ideas of the page should be:

hendryanw commented 1 month ago

Hi @fincd-aws , thank you! I agree with your suggestions.