AKS keeps creating new public ip even if a static public ip is specified at spec.loadBalancerIp
What happened:
AKS keeps creating new public ip even if a static public ip is specified at spec.loadBalancerIp.
What you expected to happen: AKS should use the public ip I specified.
How to reproduce it (as minimally and precisely as possible):
- Create a new aks cluster
- Create a public static ip address in resource group created by AKS
- Deploy a service with
spec.type=LoadBalancerandspec.loadBalancerIp=<ip address in last step> - AKS will create a load balancer but it won't use the existing ip address but create a new one.
Environment:
- Kubernetes version: 1.11.5
- Size of cluster: 2 nodes (D8s v3)
I looked into that a while ago and could not get it working either. I believe it is a limitation of the azure cloud provider in kubernetes
Looking at the code of 1.11, the spec.loadBalancerIp is being used for internal load balancers only.
https://github.com/kubernetes/kubernetes/blob/e1552d8ef9043604aae6b08b2742c9d4f3f281bc/pkg/cloudprovider/providers/azure/azure_loadbalancer.go#L678
We haven't tested on 1.11, but on 1.10, it does work for us with spec.loadBalancerIP. The only difference I see is that IP is uppercase, instead of Ip. Not sure if that matters.
We also add the annotation service.beta.kubernetes.io/azure-load-balancer-resource-group to refer to an IP in another resource group.
Cool, good to know.
It's because i'm used Ip instead of IP. Using spec.loadBalancerIP solved the issue. Thx @saykumar !