Describe the bug
We are using service.beta.kubernetes.io/aws-load-balancer-eip-allocations and service.beta.kubernetes.io/aws-load-balancer-subnets annotations to create a mapping between EIP and subnets.
As per docs , EIP allocations has this side note Length/order must match subnets
The mapping of the NLB created should be
eip-w -> subnet-random-ewewe
eip-x -> subnet-random-wewe
eip-y -> subnet-random-qrqr,
eip-z -> subnet-random-rqrq
Current outcome
The mapping which ends up being created is
Describe the bug We are using
service.beta.kubernetes.io/aws-load-balancer-eip-allocations
andservice.beta.kubernetes.io/aws-load-balancer-subnets
annotations to create a mapping between EIP and subnets. As per docs , EIP allocations has this side noteLength/order must match subnets
However this order is not respected because we end up sorting the list of subnets. https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/990ee2e98224e96ef8ec443e027dcb6ada3bb4f8/pkg/networking/subnet_resolver.go#L461
As a result, we end up mapping EIP to subnets which we don't intend (want) to
Steps to reproduce
Deployed k8s manifest example
Expected outcome A concise description of what you expected to happen.
When we set these annotations
The mapping of the NLB created should be eip-w -> subnet-random-ewewe eip-x -> subnet-random-wewe eip-y -> subnet-random-qrqr, eip-z -> subnet-random-rqrq
Current outcome The mapping which ends up being created is
eip-w -> subnet-random-ewewe eip-x -> subnet-random-qrqr eip-y -> subnet-random-rqrq eip-z -> subnet-random-wewe
Environment
Additional Context: