Integration of Curator/Zookeeper

30 views
Skip to first unread message

Oliver Komoll

unread,
Nov 26, 2015, 10:37:13 AM11/26/15
to membrane-monitor
Hi Thomas,

i want to implement a service discovery for my microservices based on curator and zookeeper. I register my services on startup with there version and a list of the supported tenants (logical databases) at zookeeper. 

I do not want to implement the discovery on the client side, cause i need also a solution for the web clients. So i came to the idea to use membrane as a configurable API-Gateway.

Do you think it is possible to implement a replacment or enhancement for the clusters (Balancer) class to describe something like

<serviceProxy name="myService" port="8080">
    <path>/service</path>
    <balancer>
        <clusters>
            <cluster zkServer="localhost:2181" basePath="services"/>
        </clusters>
        <roundRobinStrategy/>
    </balancer>
</serviceProxy>

Also i need to integrate a version number and the tenant. The tenant is stored in a header field and the required version of the service must be configured in membrane - maybe with the help of a custom interceptor - so my path for zookeeper looks like /services/myService/V1/tenant1 What do you think -is this possible - is it better to embed and configure membrane in java and "inject" the discovered server list or to enhance membrane

TIA
Oliver

Thomas Bayer

unread,
Nov 26, 2015, 10:53:36 AM11/26/15
to membrane...@googlegroups.com
Hi Oliver,
we are working on something very similar to your approach with the etcd registry. You can have a look at:

https://github.com/membrane/service-proxy/tree/master/core/src/main/java/com/predic8/membrane/core/cloud/etcd

The basic idea is that the endpoint address of a target comes from the registry ( zookeeper, etcd, ... ) and the Membrane router than uses that information to route to that endpoint.

We abstracted the publisher using spring, so you can just implement a different publisher.


Am 26.11.15 um 16:26 schrieb Oliver Komoll:
Hi Thomas,


I do not want to implement the discovery on the client side, cause i need also a solution for the web clients. So i came to the idea to use membrane as a configurable API-Gateway.
We came up with the same ;-)


Do you think it is possible to implement a replacment or enhancement for the clusters (Balancer) class to describe something like

<serviceProxy name="myService" port="8080">
    <path>/service</path>
    <balancer>
        <clusters>
            <cluster zkServer="localhost:2181" basePath="services"/>
        </clusters>
        <roundRobinStrategy/>
    </balancer>
</serviceProxy>
I would not use the loadbalancer to do that. I think the publisher is a nicer approach.

Also i need to integrate a version number and the tenant. The tenant is stored in a header field and the required version of the service must be configured in membrane - maybe with the help of a custom interceptor - so my path for zookeeper looks like /services/myService/V1/tenant1
I think you can combine the publisher with an interceptor.

What do you think -is this possible - is it better to embed and configure membrane in java and "inject" the discovered server list or to enhance membrane
You can embed it into your Java code or you can deploy it as a Web App or install it in a Docker container. It does not really matter for that problem.

Would be cool, if you can share your code so we get also support for zookeeper.

Cheers,
Thomas

TIA
Oliver
--
You received this message because you are subscribed to the Google Groups "membrane-monitor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to membrane-monit...@googlegroups.com.
To post to this group, send email to membrane...@googlegroups.com.
Visit this group at http://groups.google.com/group/membrane-monitor.
For more options, visit https://groups.google.com/d/optout.

Oliver Komoll

unread,
Nov 27, 2015, 4:09:28 AM11/27/15
to membrane-monitor
Hi Thomas,

sounds great - do you have a configuration example ?
Couldn't find the interface for the publisher - found only  the implemented EtcdPublisher, so how can i inject my own registry implementation

TIA
Oliver


Am Donnerstag, 26. November 2015 16:53:36 UTC+1 schrieb Thomas Bayer:
Hi Oliver,
we are working on something very similar to your approach with the etcd registry. You can have a look at:

https://github.com/membrane/service-proxy/tree/master/core/src/main/java/com/predic8/membrane/core/cloud/etcd

The basic idea is that the endpoint address of a target comes from the registry ( zookeeper, etcd, ... ) and the Membrane router than uses that information to route to that endpoint.

We abstracted the publisher using spring, so you can just implement a different publisher.


Am 26.11.15 um 16:26 schrieb Oliver Komoll:
Hi Thomas,


I do not want to implement the discovery on the client side, cause i need also a solution for the web clients. So i came to the idea to use membrane as a configurable API-Gateway.
We came up with the same ;-)

Do you think it is possible to implement a replacment or enhancement for the clusters (Balancer) class to describe something like

<serviceProxy name="myService" port="8080">
    <path>/service</path>
    <balancer>
        <clusters>
            <cluster zkServer="localhost:2181" basePath="services"/>
        </clusters>
        <roundRobinStrategy/>
    </balancer>
</serviceProxy>
I would not use the loadbalancer to do that. I think the publisher is a nicer approach.
...

Tobias Polley

unread,
Dec 24, 2015, 4:23:45 AM12/24/15
to membrane-monitor
Hi Oliver,

the setup Thomas described is beginning to be documented.

With the lastest Membrane build from the github master branch (a simple "mvn package -DskipTests" should do the trick), examples/service-discovery-with-etcd contains the description of the complete example.

This consists of one example node using Membrane and etcdPublisher to publish node info into etcd, and another (possibly load balancing) Membrane using etcdBasedConfigurator to automatically setup serviceProxies for all node infos found in etcd.

Please note that you don't actually have to use etcdPublisher, if the node(s) can publish itself within etcd (step 1: by basically making a bunch of HTTP calls after startup, step 2: include a TTL and repeat those calls shortly before expiration).

Best, Tobias
Reply all
Reply to author
Forward
0 new messages