Creating a Static IP Network Load Balancer in EKS

Creating a Static IP Network Load Balancer in EKS


In this article, we will be taking a deep dive into how to create a Network Load Balancer (NLB) with a static IP address for our EKS service.


One of the key requirements of deploying services in the cloud is to have a reliable and stable IP address. When we create a load balancer in AWS, it usually comes with a dynamic IP address which may change every time the load balancer is restarted. But in certain scenarios, we may require a static IP address for security reasons such as whitelisting. This is where Network Load Balancers with a static IP come in handy.

To create a NLB with a static IP, we first need to reserve Elastic IP addresses in AWS. The number of Elastic IPs required will depend on the number of availability zones in your cluster. In this example, we have a cluster with three availability zones, so we need to reserve three Elastic IP addresses.

Here are the names of the three Elastic IP addresses that we will be reserving:

  • eipalloc-xxxx1

  • eipalloc-xxxx2

  • eipalloc-xxxx3


With the Elastic IPs reserved, we can now proceed to create a service in our cluster. In the service manifest, we will add an annotation to specify the reserved Elastic IPs. Here is the annotation that we need to add: eipalloc-xxxx1,eipalloc-xxxx2,eipalloc-xxxx3

Here is a complete sample service manifest that you can use to create a NLB with a static IP:

apiVersion: v1
kind: Service
  name: nginx-nlb
  namespace: default
  annotations: external ip internet-facing eipalloc-xxxx1,eipalloc-xxxx2,eipalloc-xxxx3
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 31825
    - name: http-ssl
      protocol: TCP
      port: 443
      targetPort: 443
      nodePort: 31318
    name: nginx
  type: LoadBalancer
  sessionAffinity: None
  externalTrafficPolicy: Cluster
    - IPv4
  ipFamilyPolicy: SingleStack
  allocateLoadBalancerNodePorts: true
  internalTrafficPolicy: Cluster


In conclusion, creating a Network Load Balancer with a static IP for our EKS service can be easily done by reserving the required number of Elastic IP addresses and adding the necessary annotations in the service manifest. With the above steps, you will be able to create a secure and reliable Load Balancer with a static IP that can be used for whitelisting purposes. It is important to note that the number of reserved Elastic IP addresses must match the number of availability zones in your cluster. Additionally, the above sample service manifest can be customized based on your specific requirements, such as the number of ports, protocol, and session affinity.

If you find this article useful please leave a like and consider following.


Did you find this article valuable?

Support Abhishek Singh by becoming a sponsor. Any amount is appreciated!