apisix-helm-chart
apisix-helm-chart copied to clipboard
How to specify a static IP on LoadBalancer in Azure
I'm looking for a way to specify my LoadBalancer IP while installing APISIX on AKS in Azure.
The official documentation shows us the general installation with a few overrides:
helm repo add apisix https://charts.apiseven.com
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
# We use Apisix 3.0 in this example. If you're using Apisix v2.x, please set to v2
ADMIN_API_VERSION=v3
helm install apisix apisix/apisix \
--set gateway.type=LoadBalancer \
--set ingress-controller.enabled=true \
--create-namespace \
--namespace ingress-apisix \
--set ingress-controller.config.apisix.serviceNamespace=ingress-apisix \
--set ingress-controller.config.apisix.adminAPIVersion=$ADMIN_API_VERSION
kubectl get service --namespace ingress-apisix
The documentation continues to say:
The gateway service type will be set to LoadBalancer. You can find the load balancer IP address by running:
kubectl get service apisix-gateway --namespace ingress-apisix -o jsonpath='{.status.loadBalancer.ingress[].ip}'
This is fine perhaps for some non production scenarios, but it doesn't really give you control over which IP is being used. This can be a hassle for DNS. In addition, there's no guarantee of this dynamic IP. It's subject to changing if the LoadBalancer bounces or during upgrades. It could rotate to a new IP breaking DNS.
I'm looking for help with annotations or another configuration option to specify a pre-existing static Azure IP instead of rolling the dice and being at the mercy of dynamic IP rotation.
The NGINX ingress controller, by contrast has a fairly simple way of handling this with the following annotations.
- Create an AKS cluster
- Create a static IP address in Azure in the cluster's resource group
- Install or upgrade the NGINX helm chart with the specified load balancer IP
STATIC_IP=<your static IP here>
helm upgrade --install ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx \
--create-namespace \
--set rbac.create=true \
--set controller.stats.enabled=true \
--set controller.metrics.enabled=true \
--set controller.service.externalTrafficPolicy="Local" \
--set controller.service.loadBalancerIP=$STATIC_IP
This is also affecting us on migrating from Nginx Ingress towards APISIX.
You can set the service annotations for gateway service here https://github.com/apache/apisix-helm-chart/blob/master/charts/apisix-ingress-controller/templates/service-apisix.yaml#L6-L8
Following the MIcrosoft documentation here https://learn.microsoft.com/en-us/azure/aks/static-ip
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.kubernetes.io/azure-load-balancer-resource-group: <node resource group name>
service.beta.kubernetes.io/azure-pip-name: myAKSPublicIP
name: azure-load-balancer
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: azure-load-balancer
So the helm values is
...
spec:
values:
gateway:
type: LoadBalancer
annotations:
service.beta.kubernetes.io/azure-pip-name: myAKSPublicIP
service.beta.kubernetes.io/azure-load-balancer-resource-group: <node resource group name>