How to Change the Public IP to Elastic IP in NetworkLoadbalancer

2/14/2019

As of now we can create NLb from K8s with this annotation "service.beta.kubernetes.io/aws-load-balancer-type: "nlb". It will take take available Public IP in the subnet.

So is it possible to change the SubnetMapping with the Elastic IP from AWS CLI once NLB is created? If yes can anyone give an example.

I tried to update the Subnet mapping on NLB which was created by K8s using service annotation.

aws elbv2 set-subnets --load-balancer-arn arnValue --subnet-mappings SubnetId=abcd,AllocationId=eipalloc-1 --region us-east-1

Output was SetSubnets is not supported for load balancers of type 'network'

-- Karthik
amazon-ec2
amazon-eks
amazon-web-services
kubernetes
nlb

1 Answer

2/14/2019

Elastic IP can be attached or changed only while creating the Network Load Balancer. Secondly, ´set-subnets´ works only for Application Load Balancer.

You will need to recreate this Network Load Balancer to achieve your goal. Hope this helps.

Please refer- https://forums.aws.amazon.com/thread.jspa?threadID=263577 https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_SetSubnets.html

-- Sree1439
Source: StackOverflow