~/home/ilias

/

Upgrade AKS Basic loadbalancer to a Standard loadbalancer

When you created an AKS cluster in the past, Azure automatically created a Basic load balancer with it. Now Azure offers two kinds of load balancers. A Basic load balancer and a Standard load balancer. There are a bunch of differences between the two load balancers. I will not get into the differences in this post. You can compare the two load balancers here

For some reason it is not possible to upgrade an AKS cluster with a Basic load balancer easily to the standard load balancer. But there is a small trick you can perform to upgrade the load balancer to the standard type.

I already have upgrade all my load balancers to standard, so for this post I’ll be creating a new cluster with a Basic load balancer.

az aks create --resource-group resource_name --name TestCluster2 /
--node-count 2 --enable-addons monitoring --generate-ssh-keys /
--load-balancer-sku basic

As you can see here I now have a new cluster with Basic SKU.

Alt text

Now lets connect to the cluster and create the load balancer with the following yaml file.

public-svc.yaml

apiVersion: v1
kind: Service
metadata:
name: public-svc
spec:
type: loadBalancer
ports:
- port: 80
selector:
        app: public-app
kubectl apply -f public-svc.yaml

If we go to the Azure portal and check our load balancers we can now see that we have a public load balancer with Basic SKU. When you create a load balancer we will automatically get one with Basic SKU because the AKS cluster is also Basic SKU.

Alt text

Now we want to upgrade the load balancer to a Standard SKU.

Let’s create a temporarly Standard load balancer in the same resource group as the Basic load balancer. We need to create a temp load balancer because Azure won’t let you delete a load balancer if there are no other load balancers listed.

Alt text

Now let’s delete the Basic load balancer we have created at the beginning.

kubectl delete service public-svc

Alt text

We need to create a new Standard load balancer with the same name as the one we just deleted. I will create this load balancer trough the Azure portal. After this we can delete the temp load balancer trough the portal.

Alt text

We have one load balancer left and that is the Standard load balancer named ‘kubernetes’. BUT the backend-pool, health-probes and routes aren’t configured yet. To fix this I have to re-run the ‘public-svc.yaml’ file. But first we need to edit it and define a static IP. We will be using the ip of the standard load balancer. You can find the IP in the Azure portal.

apiVersion: v1
kind: Service
metadata:
name: public-svc
spec:
load balancerIP: 51.124.X.X < (YOUR IP HERE)
type: loadBalancer
ports:
- port: 80
selector:
        app: public-app
kubectl apply -f public-svc.yaml

As you can see, we now have a AKS cluster with Basic SKU but with a Standard load balancer. The backend-pools and healthprobes are also configured automatically.

Alt text

Good to know: If you want to keep your original load balancer IP you can upgrade the public ip from the basic SKU to the standard SKU. See details here .

Reply via email