Creating flexible OCI Load Balancers with OKE

Until recently, the OCI Load Balancer shapes were fairly restricted to a handful:

  • 100 Mbps
  • 400 Mbps
  • 8000 Mbps

What’s more, if you had to change the shape, that would involve recreating the load balancer. Not anymore.

There’s now a couple of new load balancer shapes:

Load balancer shapes are also now updatable without having to destroy and recreate them.

So let’s see how we can create them with OKE.

First, let’s see what load balancer shapes are available in our tenancy

oci lb shape list --compartment-id ocid1.compartment.oc1..                                                      
{
"data": [
{
"name": "100Mbps"
},
{
"name": "10Mbps"
},
{
"name": "10Mbps-Micro"
},
{
"name": "400Mbps"
},
{
"name": "8000Mbps"
},
{
"name": "flexible"
}
]
}

As you can see, all the shapes are available. I could use a simple service to have the load balancer created but I want to show that these work equally well with ingress controllers, so let’s use the NGINX Ingress Controller to create one.

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install nginx ingress-nginx/ingress-nginx

By default, this will create a load balancer of shape 100 Mbps:

oci lb load-balancer get --load-balancer-id ocid1.loadbalancer...."shape-name": "100Mbps",...

Let’s say we want to change the shape to 400 Mbps. We can do this with a load balancer annotation and a helm upgrade:

helm upgrade nginx ingress-nginx/ingress-nginx \
--set controller.service.annotations."service\.beta\.kubernetes\.io/oci-load-balancer-shape"="400Mbps"

TIP: If you want to avoid the horrible escapes and \, use the values.yaml file provided by the chart. All you would need to do is traverse to the annotations section and add the following:

service.beta.kubernetes.io/oci-load-balancer-shape: "400Mbps"

After the upgrade is done, we can check on the shape again as before and we can see it’s now been upgraded to 400 Mbps:

...
"shape-name": "400Mbps",
...

Now, let’s say we want to create one with the flexible shape and want to take the opportunity to set the bandwidth limits. We can do this passing the following annotations:

helm install nginx ingress-nginx/ingress-nginx \ 
--set controller.service.annotations."service\.beta\.kubernetes\.io/oci-load-balancer-shape"="flexible" \
--set controller.service.annotations."service\.beta\.kubernetes\.io/oci-load-balancer-shape-flex-min"=100 \
--set controller.service.annotations."service\.beta\.kubernetes\.io/oci-load-balancer-shape-flex-max"=200

When we check on the shape, we see the following:

"shape-details": {                                                                                                                                                                        
"maximum-bandwidth-in-mbps": 200,
"minimum-bandwidth-in-mbps": 100
},
"shape-name": "flexible",

We can also dynamically change the bandwidth:

helm upgrade nginx ingress-nginx/ingress-nginx --set controller.service.annotations."service\.beta\.kubernetes\.io/oci-load-balancer-shape"="flexible" --set controller.service.annotations."service\.beta\.kubernetes\.io/oci-load-balancer-shape-flex-min"=10 --set controller.service.annotations."service\.beta\.kubernetes\.io/oci-load-balancer-shape-flex-max"=500

And now we check on the shape, we can see the changes reflected:

"shape-details": {                                                                                                                                                                        
"maximum-bandwidth-in-mbps": 500,
"minimum-bandwidth-in-mbps": 10
},
"shape-name": "flexible",

If you were wondering how to use the new shapes or how to use the update feature, I hope you find this post useful.

Finally, all the OCI Load Balancer annotations can be found here: https://github.com/oracle/oci-cloud-controller-manager/blob/master/docs/load-balancer-annotations.md which allows you to control the behaviour of the load balancers created by OKE.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store