Skip to content

Pod does not have outbound network on EC2

0

I have a kubernetes cluster consisting of node groups and fargate.

I have some pods deployed to the EC2 nodes. The EC2 nodes have public network access, so it can either pull docker images or curl www.example.com. The pods deployed on EC2, however, fail to connect to the public network, even though it resolved the address. The pods deployed on Fargate have access to the public network.

asked 2 years ago428 views

2 Answers
0

OK, it seems to be caused by the AWS_VPC_K8S_CNI_EXTERNALSNAT configuration on aws-node that I set to allow Fargate pods to access network.

answered 2 years ago

-1

The issue you're experiencing with pods on EC2 nodes not having outbound network access, while the EC2 instances themselves can connect, is likely related to the network address translation (NAT) configuration for the pods. Here are a few points to consider and potential solutions:

  1. By default, when a pod communicates with an IPv4 address outside of the VPC, the Amazon VPC CNI plugin translates the pod's IP address to the primary private IPv4 address of the node's elastic network interface. This translation might not be occurring correctly in your case.

  2. Check if your Amazon VPC CNI plugin version is up to date. Older versions may have issues with network address translation for pods.

  3. Ensure that the EC2 instances are in a public subnet and have a public or elastic IP address assigned. Pods can only communicate with internet resources if the node they're running on meets these criteria.

  4. If your pods are in a private subnet and need to communicate outbound to the internet, you may need to adjust the CNI plugin configuration. You can do this by running the following command:

kubectl set env daemonset aws-node -n kube-system AWS_VPC_K8S_CNI_EXTERNALSNAT=true

This enables external source network address translation (SNAT) for pods.

  1. If you're using custom networking to deploy pods in alternate subnets, ensure that the subnets and security groups for the pods are properly configured and are in the same VPC as the node.

  2. If IPv6 is enabled for your cluster, the behavior might be different as IPv6 addresses are not network translated. In this case, ensure your VPC and subnet configurations support IPv6 traffic correctly.

If these steps don't resolve the issue, you may need to review your cluster's network configuration, including VPC settings, security groups, and network ACLs, to ensure there are no restrictions preventing pod traffic.

Sources
Enable outbound internet access for pods - Amazon EKS
Deploy pods in alternate subnets with custom networking - Amazon EKS
Configure the Amazon VPC CNI plugin for Kubernetes for security groups for Amazon EKS Pods - Amazon EKS

answered 2 years ago

EXPERT

reviewed 2 years ago

  • I have reviewed all of them but didn't find any potential issues.

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.