I have a simple use case; I have 4 Microservices lets say service-a, service-b, service-c, service-d.
For the purpose of testing, I want to split traffic based on weight like
- 40% to service-a
- 20% to service-b
- 10% to service-c
- 30% to service-d
Considering they will be accessed over same path: example.com/
I am planinng to go with NGINX Ingress Controller but I saw a limitation on documentation: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#canary
Currently a maximum of one canary ingress can be applied per Ingress rule.
There is a GitHub issue too related to the same: https://github.com/kubernetes/ingress-nginx/issues/5848
I am not able to understand what does this actually mean and will this limitation not allow me implement with 4 services. Does that mean I have to create 4 canary ingress with single ingress rule for all 4 services? All the example for traffic splitting using ingress controller is of 2 services. should I consider Istio as it does not have this limitation
Can someone please explain me with simple yaml code example about this limitation?
2
Answers
If you need to implement traffic splitting across multiple microservices in AKS using a load balancer like NGINX Ingress Controller, and are facing limitations with the canary configuration, a better approach could be using Istio, a service mesh that provides advanced traffic management capabilities.
install and setup istio first
Create Deployment and Service for Each Microservice (
service-a
,service-b
,service-c
, andservice-d
) using your docker image ( I’ll usenginxdemos/hello
image here)repeat for b, c and d same way as above and apply
kubectl apply -f <filename>.yaml
next steps involve setting up the Istio Gateway and Virtual Service to handle the traffic distribution according to your specified weights. This will enable you to route incoming traffic to your services
service-a
,service-b
, andservice-c
at the specified ratiosCreate Istio Gateway
Create Istio VirtualService
Adjust the
namespace
,host
, andport
parameters accordinglykubectl get svc istio-ingressgateway -n istio-system
You can now verify the VirtualService Configuration if it is matching your split –
The docs you mention are from the community ingress controller, however
this is possible using NGINX Ingress Controller’s
VirtualServer
CRD. NGINX Ingress Controller’s docs are here.There is a traffic splitting example in the examples folder in the repo, which I have modified slightly to be similar to your example.
In NGINX Ingress Controller the limitation on the number of splits would be 100, as only whole numbers are allowed currently in the CRD, and the weights must add up to 100.