Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws-load-balancer-eip-allocations does not work. Assign static IP to LoadBalancer service using k8s on AWS

I use aws-load-balancer-eip-allocations assign static IP to LoadBalancer service using k8s on AWS. The version of EKS is v1.16.13. The doc at https://github.com/kubernetes/kubernetes/blob/v1.16.0/staging/src/k8s.io/legacy-cloud-providers/aws/aws.go#L208-L211, line 210 and 211 says "static IP addresses for the NLB. Only supported on elbv2 (NLB)". I do not know what the elbv2 is. I use the code below. But, I did not get static IP. Is elbv2 the problem? How do I use elbv2? Please also refer to https://github.com/kubernetes/kubernetes/pull/69263 as well.

apiVersion: v1
kind: Service
metadata:
  name: ingress-service
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
    service.beta.kubernetes.io/aws-load-balancer-eip-allocations: "eipalloc-0187de53333555567"
    service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
like image 853
Melissa Jenner Avatar asked Dec 10 '25 07:12

Melissa Jenner


1 Answers

have in mind that you need 1 EIP per subnet/zone and by default EKS uses a minimum of 2 zones.

This is a working example you may found useful:

metadata:
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
    service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: 'true'
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
    service.beta.kubernetes.io/aws-load-balancer-subnets: "subnet-xxxxxxxxxxxxxxxx,subnet-yyyyyyyyyyyyyyyyy"
    service.beta.kubernetes.io/aws-load-balancer-eip-allocations: "eipalloc-wwwwwwwwwwwwwwwww,eipalloc-zzzzzzzzzzzzzzzz"

I hope this is useful to you

like image 127
William Añez Avatar answered Dec 11 '25 21:12

William Añez