Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EKS in private Subnet , Load Balancer in public subnet

I am running EKS in private subnet and thus unable to create an internet facing load balancer but was able to create Internal LoadBalancer.

Is there any way I can create Loadbalancer(probably Manually) in public subnet and point to the pods running in EKS in the private subnet.

I was thinking of creating the chain of load balancer in which External load balancer will point to internal load balancer but that too is not possible as the IP address of the internal load balancer is reserved IP.

Can I try some other way to route the traffic from the internet to pod?

like image 370
R-JANA Avatar asked Jan 03 '19 17:01

R-JANA


People also ask

Can public subnet talk to private subnet AWS?

The instances in the public subnet can send outbound traffic directly to the internet, whereas the instances in the private subnet can't. Instead, the instances in the private subnet can access the internet by using a network address translation (NAT) gateway that resides in the public subnet.

How do I connect to AWS private subnet from a public subnet?

If you want to access your private subnet from outside of the VPC you need to add a bastion host to the public subnet. The bastion host should have a security group which only allows connections from the IP of your personal machine (if this is where your accessing from).

Do you need load balancer with EKS?

If your pods run on Windows in an Amazon EKS cluster, a single service with a load balancer can support up to 1024 back-end pods. Each pod has its own unique IP address. We recommend only creating new Network Load Balancers with the AWS Load Balancer Controller.

Can I deploy EKS to a dedicated VPC?

However, if you have them in your VPC, you can deploy self-managed nodes and Kubernetes resources to these types of subnets. The subnets must use IP address based naming. Amazon EC2 resource-based naming isn't supported with Amazon EKS. The subnets can be a public or private.


1 Answers

I had the same issue and it was because I did not tag the VPC subnets properly: https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html

I had to add the key: kubernetes.io/cluster/{eks-cluster-name} value: shared tag to the VPC

Then you can create a LB using a service with the type LoadBalancer

apiVersion: v1
kind: Service
metadata:
  name: helloworld
  labels:
    app: helloworld
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: helloworld
  type: LoadBalancer

This might help during the service creation: https://blog.giantswarm.io/load-balancer-service-use-cases-on-aws/

like image 193
aovelhanegra Avatar answered Oct 04 '22 19:10

aovelhanegra