I was wondering what the correct way to split traffic with x % to deployment A and y % to deployment B is. In the kodekloud learning platform, they suggested, to just scale the number of replicas from A and B to certain numbers of replicas in order to obtain the desired ratio. But what if I want a 90% and 10% traffic split without having to spin up 9 replicas on deployment A and have only 1 for deployment B ? I wasn’t able to find anything about this topic in the documentation, I’ve only found third party extensions for this, but I would like to stick with the native api. Can the ingresses be configured somehow in order to do this?
Asked
Active
Viewed 53 times
0
-
Does this answer your question? [Kubernetes Ingress - Load balancer traffic split](https://stackoverflow.com/questions/65795438/kubernetes-ingress-load-balancer-traffic-split) – YK1 Jan 04 '23 at 10:07
1 Answers
3
Currently such behavior isn't provided by native K8s API's. You can "fake" this by using two different Deployments with Labels that match one Service, however as you've already mentioned this only works if you have a certain amount of Pods running and is not really scaleable in any way.
You can use a "third party" such as Argo Rollouts for such cases: https://argoproj.github.io/argo-rollouts/concepts/#canary
Also some Ingress Controller's such as the NGINX Ingress Controller supports Canary releases: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#canary
That being said, there's nothing wrong with using third party products especially such as Argo, which recently graduated to Graduated in CNCF.

Mike
- 401
- 5
-
Thank you for your answer. "Currently such behavior isn't provided by native K8s API's." I am wondering why this is a question then in the official CKAD exam. I saw this question there (with 8% weight (!)) and was not able to find an answer to it. There is n answer to it in the slides and also not in the k8s documentation... – harrisonfooord Jan 04 '23 at 10:21
-
2@harrisonfooord I'm very well aware that this question is in the exam curriculum of the CKAD exam and is being asked (got such a question myself when I did CKAD), however this usually just includes deploying a second application or manipulating a existing service to "include" two applications. True Canary/Blue-Green Deployments are still not implemented by native K8s. – Mike Jan 04 '23 at 10:53
-
"this usually just includes deploying a second application or manipulating a existing service to "include" two applications" How can this be used to route certain percentages of traffic to app A and B ? Just spin up different numbers of replicas to reflect the ratio asked for (so 20% / 80% would be 1 replica / 4 replicas) ? – harrisonfooord Jan 04 '23 at 11:33
-
2Yes exactly, this is the only way to fake distribute a certain percentage with native K8s API's. – Mike Jan 04 '23 at 11:46