Search code examples
azurekubernetesazure-aksnginx-ingressazure-load-balancer

How to assign public IP address from old cluster to new cluster


I just created a new AKS cluster that has to replace an old cluster. The new cluster is now ready to replace the old one, except for one crucial thing, it's outbound ip address. The address of the old cluster must be used so that our existing DNS records do not have to change.

How do I change the public IP address of the Azure load balancer (that is used by the nginx ingress controller) of the new cluster to the one used by the old cluster? The old cluster is still running, I want to switch it off / delete it when the new cluster is available. Some down time needed to switch the ip address is acceptable.

I think that the ip first has to be deleted from the load balancer's Frontend IP configuration of the old cluster and can then be added to the Frontend IP configuration of the load balancer used in the new cluster. But I need to know exactly how to do this and what else need to be done if needed (maybe adding a backend pool?)

Update

During the installation of the new cluster I already added the public ip address of the load balancer of the old cluster in the yaml of the new ingress-nginx-controller. The nginx controller load balancer in the new cluster is in the state Pending and continuously generating events with message "Ensuring Load Balancer". Could it be that simple that I only need to assign an other ip address to the ingress-nginx-controller load balancer in the old cluster so that the ip can be used in the new cluster?


Solution

  • I managed to assign the old ip to the new cluster. These are the steps that I followed:

    1. Create a new static and public ip in the old cluster (nn.nn.nn.nn):

      az network public-ip create --resource-group MC_rg-my-old-cluster \
      --name aks-public-ip-tmp --sku Standard --allocation-method static \
      --query publicIp.ipAddress -o tsv
      
    2. Put the new ip in the load balancer service of the nginx controller:

       spec.ports.loadBalancerIP: nn.nn.nn.nn
      
    3. Move old ip address (oo.oo.oo.oo) to the resource group of the new cluster:

      • Find the resource group of the old cluster and open it;
      • Click on the public ip address that you want to move;
      • In the menu on the top there is a 'Move' item, select "Move to another resource group"
      • Select the resource group of the new cluster
    4. After the ip is moved (can take a while) you can use it in the load balancer service of the nginx controller in the new cluster:

      spec.ports.loadBalancerIP: oo.oo.oo.oo
      

    I don't know if steps 1 and 2 are really needed.