Setup Anypoint Flex Gateway on the Kubernetes as an Ingress Controller in Connected Mode — Part IV
Introduction
In the last tutorial, we have walkthrough how to enable TLS on the ingress and publish the API on HTTPS ingress.
In this tutorial, we will be talking about how to implement High Availability and Auto Scaling with Flex Gateway on the Kubernetes as an Ingress Controller.
High Availability can be implemented in the Flex Gateway by deploying multiple replicas on the ingress and this will ensure Business Continuity, Scaling and load distribution across the multiple replicas.
To deploy multiple replicas of the ingress, we can pass replicaCount parameter as part of Helm chart command for installing or upgrading the ingress.
helm -n gateway upgrade -i — create-namespace — wait ingress flex-gateway/flex-gateway \
--set-file registration.content=registration.yaml \
--set replicaCount=2
This above command will setup the two replicas of ingress and this can be validate on Anypoint Flex Gateway and Kubernetes dashboard.
In above, we can see multiple pods has been created as we have passed replicaCount=2 in above helm command.
Autoscaling is features where it will automatically scale up or scale down the number of replicas to Flex Gateway depending on CPU and Memory Utilization. To enable Autoscaling, we need to pass few parameters while creating or upgrading ingress using Helm.
To enable autoscaling, we can use below command.
helm -n gateway upgrade -i --create-namespace --wait ingress flex-gateway/flex-gateway \
--set-file registration.content=registration.yaml \
--set replicaCount=2 \
--set autoscaling.enabled=true \
--set autoscaling.minReplicas=2 \
--set autoscaling.maxReplicas=8 \
--set autoscaling.targetCPUUtilizationPercentage=80 \
--set autoscaling.targetCPUUtilizationPercentage=80
This command will automatically add or remove replica depending on CPU and Memory utilization. In our case, it will always keep minimum of 2 replicas and can scale up to 8 replicas.
Uninstall the Flex Gateway from MiniKube
To uninstall the Flex Gateway from MiniKube, we need to execute the below list of commands.
Remove the helm release from the MiniKube.
helm delete my-release
This command will delete the helm release named “my-release”.
Delete the namespace “gateway” that we have created during setup of Flex Gateway during part 1 of the tutorial.
kubectl delete namespace gateway
This command will remove the namespace gateway,
Delete the custom resource definition using below command.
kubectl delete crds \
apiinstances.gateway.mulesoft.com \
configurations.gateway.mulesoft.com \
extensions.gateway.mulesoft.com \
policybindings.gateway.mulesoft.com \
services.gateway.mulesoft.com
References
This is how we can implement High Availability and Auto Scaling with Flex Gateway on the Kubernetes.