Spring Cloud: Canary Deployments with Zuul
Asked Answered
R

1

17

I am getting started with Spring Cloud using Eureka and Zuul and had some questions around structuring blue/green and Canary deployments. So far, I have the basics worked out and have Eureka, Zuul, and a config server working as expected. What I am trying to accomplish is set up a service that has two versions, say 1.0 and a 1.1. For a subset of specific users, I want to route them to the 1.1 version and everyone else should go to the 1.0 version.

The Zuul filter API is a little light on documentation and I'm struggling a bit to grok some of the concepts, so I thought I'd ask a few questions here. I have also have some basic filters running, which don't do a whole lot a the moment other than getting the identity of the principal and the service they are requesting. Where I am hitting a wall is understanding how to expose two different versions of the same service to Eureka and Zuul. A few things I'm curious about:

  • Between documentation, posts, and other stack overflow, the term "service" and "cluster" seem to be used interchangeably. Is this correct?
  • With that said if I have a service named /simpleservice do I expose two different serviceIDs (i.e. simpleservice and simpleservice-1.1 )? And If I do that, when one of the targeted users requests /simpleservice, I'm having Zuul send them to /simpleservice-1.1
  • Or, do you add another node to the existing service ID and add additional metadata to each node so that Zuul and distinguish versions 1.0 and 1.1?
  • Is the correct answer "all of the above?" :)
Rior answered 3/8, 2015 at 11:27 Comment(0)
A
7

Assuming you are using Ribbon as well, I would leave the service IDs as they are. Instead I would take a look at the com.netflix.loadbalancer package. Canary deployments are essentially load balancing with very specific constraints. You could implement your own AbstractLoadBalancerRule that picks servers based on some property you would like to base the routing on. Then add that rule to the configuration of your Zuul instance.

@Configuration
public class CanaryConfiguration {
    @Bean public IRule canaryDeploymentRule(IClientConfig config) {
      CanaryDeploymentRule rule = new CanaryDeploymentRule ();
      rule.initWithNiwsConfig(config);
      return rule;
    }
}

If you let your services register themselves in Eureka with different service IDs ("simpleservice" and "simpleservice-x.y"), I suppose things are bound to become complicated. You would have to extend the discovery client to ignore the version part ("-x.y", while still being able to deal with "foo-service") when retrieving the list of available servers from Eureka and then do some selection process to pick the right one anyway. So I guess things would just become more complex.

This is all based on best guesses, I haven't actually implemented this. I realize that this question is almost 4 months old. So if you have found some other solution in the meantime, it would be great if you could share it in an answer to your own question.

Apery answered 26/11, 2015 at 8:17 Comment(4)
We were using Zuul with Ribbon, but I didn't think to look at the Ribbon project for the rule examples. This helps a lot. I'll post back once we dive in deeper.Rior
@Ryan I'd be very interested to learn, how you solved your problem?Mesoderm
Have you dive in deeper @RyanJ.McDonough ?Spatterdash
I'm interested too. we will have 100 clients and I want to canary test with 10 specific, uniquely identifiable clients. Client app does not change, just internals of microservice. How do i configure the gateway(?) to route requests to the new version of the microservice for THESE 10 CLIENTS without changing anything in clientGwendolin

© 2022 - 2025 — McMap. All rights reserved.