Search code examples
amazon-web-serviceskubernetesamazon-eksnat

EKS cluster pods unable to connect to internet


I have created an EKS private cluster along with a node group. I'm accessing the cluster through the bastion host. I'm able to access the cluster and run the pods in the cluster but the pods don't have any internet access.

EKS nodes have internet access and it is able to pull the public docker images but the pods running inside it don't have internet access. I'm not using any different networking like calico or anything.

Can someone please help to fix this issue?


Solution

  • Below are the troubleshooting steps for your problem:

    By default pods are not isolated and they will accept traffic from any source. Please check whether you have met networking requirements or not from this page.

    You need to expose your pods to the service

    Ex:

    $ kubectl run nginx --image=nginx --replicas=5 -n web deployment.apps/nginx created
    
    $ kubectl expose deployment nginx --port=80 -n web service/nginx exposed
    
    $ kubectl get svc -n web NAME    TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE nginx   ClusterIP   10.100.94.70   <none>  80/TCP    2s
    
    # kubectl exec -ti busybox -n web -- nslookup nginx Server:    10.100.0.10 Address 1: 10.100.0.10 ip-10-100-0-10.ap-southeast-2.compute.internal Name:      nginx Address 1: 10.100.94.70 ip-10-100-94-70.ap-southeast-2.compute.internal
    

    And if it fails; check DNS troubleshooting.

    • If you use any security groups to the pods then you need to confirm whether there is any communication to the group or not.
    • Check ACL does not deny any connection.
    • Subnets should have the default route communications within the VPC.
    • Check whether you have enough IP addresses.
    • Your pods should be scheduled and should be in the running state.
    • Finally check the version and whether it is compatible or not.