Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I assign a static IP to my EKS service?

I have an EKS cluster.

I created my service and exposed it using ingress-nginx.

ingress-nginx external IP appears as a DNS name and not as IP.

How can I connect my private domain to point to my EKS service?

I know that there is an annotation for using AWS Elastic IP with Kubernetes,

but it's only available starting from Kubernetes 1.16 and EKS supports only up to 1.14.

So what are my options to assign some static IP to my service and configure my DNS to point this IP?

like image 751
alexarsh Avatar asked Feb 06 '20 13:02

alexarsh


People also ask

How do I set a static IP address for Kubernetes?

Allocate static IPs under Networking > External IP addresses, either: Deploy once without loadBalancerIP , wait until you've an external IP allocated when you run kubectl get svc , and look up that IP in the list on that page and change those from Ephemeral to Static.

How do I set a static IP address for Kubernetes load balancer?

To create a LoadBalancer service with the static public IP address, add the loadBalancerIP property and the value of the static public IP address to the YAML manifest. Create a file named load-balancer-service. yaml and copy in the following YAML. Provide your own public IP address created in the previous step.

How many IP addresses does EKS use?

The EKS node is of type m3. 2xlarge and has at least 1 pod scheduled on it. Hence, during the node attach process, the instance has 2 ENIs (active and standby) attached and 60 IP addresses allocated (2 primary IP's + 2*29 secondary IP's).


2 Answers

When creating LoadBalancer service (which will create an actual load balancer), you can now specify preallocated Elastic IPs by id via annotations.

Example:

apiVersion: v1
kind: Service
metadata:
  name: some-name
  annotations:
    # only network load balancer supports static IP
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
    # comma-separated list of Elastic IP ids
    # the length of the list must be equal to the number of subnets
    service.beta.kubernetes.io/aws-load-balancer-eip-allocations: eipalloc-abcd0000,eipalloc-abcd0001,eipalloc-abcd0002
  ...
spec:
  type: LoadBalancer
  ...
like image 112
Thunderbeef Avatar answered Oct 16 '22 16:10

Thunderbeef


Assigning Static IP Address to AWS Load Balancer

The answer to this post still rings true in this case.

The way Amazon does load balancing is it will scale up and down interfaces as needed to handle the request load. This is why they assign you a domain name instead of an IP address since your load balancer could have multiple physical interfaces and the IP addresses will frequently change.

If all you are trying to do is create a DNS name for your load balancer, this can simply be done with any DNS provider by creating a CNAME record pointing to the dns name of the load balancer provisioned by AWS. If you are using Route53, it is even simpler since you can just create an A record with an alias to the DNS name.

I hope this helps. FWIW, it is not possible to get a single static IP address for your load balancer unless you are only deploying it in one Availability Zone.

like image 39
Noah Krause Avatar answered Oct 16 '22 16:10

Noah Krause