Context: Kubernetes (1.23), 2 Deployments of the same app with different version/config/etc., 1 Service

Let's say I have a web application deployed in Kubernetes using a Deployment. I want to add a new (canary, A/B testing) version of the same app as a new separate Deployment, so we're not touching the original Deployment. I want to set fixed ratio of traffic between these two Deployments.

Is it possible to achieve this using Service, or other Kube native objects? (Not by utilizing a service mesh).

2 Answers 2


Closest solution I found so far is creating those two deployments with such number of pod replicas, that corresponds to the required ratio (or close to it). I.e. if the required ratio is 7:3, Deployment A would have 7 pods, Deployment B would have 3. Service being simple round-robin, should ensure the requests spread according to the ratio.

It's not a very elegant solution though, this might be quite a big waste of resources in some cases.


To keep a ratio between N deployments, you can use the HorizontalPodAutoscaler. One of your deployments is autoscaled on your traffic (for example average traffic per pod) and the other ones are autoscaled based on their relative weight (deployment target weight / sum of the weight of the deployments).

Implementation details: you actually have to autoscaled on the inverse of the weight as the number of pods is inversely proportional to the weight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.