You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Lasindu Charith <la...@wso2.com> on 2015/08/16 04:35:13 UTC

How to incorporate a LB with a Stratos Application/Cartridge

Hi devs,

Suppose I configured an external LB such as Nginx, HAproxy etc. Now I need
to use it in my Stratos application.

Previously in 4.0.0 there was a LB property in Cartridge definition[1
<https://cwiki.apache.org/confluence/display/STRATOS/4.0.0+Sample+Cartridge+Definition>],
but seems like it's not there anymore in 4.1.0[2
<https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Cartridge+Resource+Definition>]
or in [3
<https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java>
].

    "loadBalancer":{
         "type":"lb",
         "property":{
            "name":"default.load.balancer",
            "value":"true"
         }
    }

Some product configurations needs LB ip/port and in UI too we should show
the LB IP along with the proxy port as the Access URL. Is there a way to do
this?

In addition, if we are using kubernetes, one of the minion IPs can be(are)
used as a load-balancer. In that case, how do we decide which IP to use?
(say we have 3 minions and service can be accessed using any of the 3
minion IPs : kubernetes service port)


[1]
https://cwiki.apache.org/confluence/display/STRATOS/4.0.0+Sample+Cartridge+Definition
[2]
https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Cartridge+Resource+Definition
[3]
https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java

Thanks,
-- 
*Lasindu Charith*
Software Engineer, WSO2 Inc.
Committer & PMC Member, Apache Stratos
Mobile: +94714427192 | Web: blog.lasindu.com

Re: How to incorporate a LB with a Stratos Application/Cartridge

Posted by Imesh Gunaratne <im...@apache.org>.
IMO following are the scenarios how we can use a load balancer:

   - External load balancer - VM
      - Might need to define in the cartridge/network partition definition
      - Proxy ports need to be updated in the server


   - External load balancer, Kubernetes services - Docker
      - Might need to define in the cartridge/network partition definition
      - Proxy ports need to be updated in the server (to external load
      balancer ports)


   - Kubernetes services - Docker - Without external load balancer
      - Proxy ports need to be updated in the server (to Kubernetes service
      ports)


   - Internal load balancer (defined in the application) - VM
      - Need to identify using dependencies
      - Proxy ports need to be updated in the server (to internal load
      balancer ports)


   - Internal load balancer (defined in the application), Kubernetes
   Services - Docker
   - Might not make sense to deploy the load balancer within the same
      Kubernetes cluster since nginx/Kubernetes services are already available
      - Need to identify using dependencies
      - Proxy ports need to be updated in the server (to internal load
      balancer ports)

*Options for configuring External Load Balancers:*

   - Publishing to Metadata service might not be feasible since the
   application Token is not available to the end user.
   - +1 for defining a load balancer section in the cartridge definition.
   This would be much readable (even for internal load balancers). Shall we
   have something as follows:
   - Proxy ports can be found in the port mappings section of the same
   cartridge.

"loadBalancer": {

    "name": "haproxy-external-lb",

    "type": "external",
    "ipAddress": "10.0.10.2",
    "hostname": "mycloud.com"
}


"loadBalancer": {

    "name": "nginx-internal",

    "type": "internal",
    "alias": "nginx-1",
}


On Sun, Aug 16, 2015 at 11:59 AM, Lasindu Charith <la...@wso2.com> wrote:

> Hi Akila
>
> On Sun, Aug 16, 2015 at 11:32 AM, Akila Ravihansa Perera <
> ravihansa@wso2.com> wrote:
>
>> Hi Lasindu,
>>
>> I think your question is about using LB properties (IP, port, hostname)
>> inside the cartridge instance. We can pass those parameters in the
>> cartridge definition as payload parameters as a simple solution. We can
>> also publish those information in meta-data service as well. Publishing to
>> meta-data service will be more flexible since we can easily update those
>> values without having to redeploy cartridges etc.
>>
>> Yes, this seems to be the simplest solution. but is it OK to generate an
> access URL from Stratos, based on a custom parameter?
> IMO, it would be better to have a separate section for LB similar to 4.0.0?
>
>
>> Regarding Kubernetes scenario, we need to have an external LB which would
>> forward requests to all the upstream minion instances. Then use that
>> external LB within all pods (services can be differentiated through
>> different hsotnames)
>>
>> Yes, this seems to be the better approach.
>
>
>> This is just my suggestion. Perhaps there is a better way.
>>
>> Thanks.
>>
>> On Sun, Aug 16, 2015 at 8:05 AM, Lasindu Charith <la...@wso2.com>
>> wrote:
>>
>>> Hi devs,
>>>
>>> Suppose I configured an external LB such as Nginx, HAproxy etc. Now I
>>> need to use it in my Stratos application.
>>>
>>> Previously in 4.0.0 there was a LB property in Cartridge definition[1
>>> <https://cwiki.apache.org/confluence/display/STRATOS/4.0.0+Sample+Cartridge+Definition>],
>>> but seems like it's not there anymore in 4.1.0[2
>>> <https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Cartridge+Resource+Definition>]
>>> or in [3
>>> <https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java>
>>> ].
>>>
>>>     "loadBalancer":{
>>>          "type":"lb",
>>>          "property":{
>>>             "name":"default.load.balancer",
>>>             "value":"true"
>>>          }
>>>     }
>>>
>>> Some product configurations needs LB ip/port and in UI too we should
>>> show the LB IP along with the proxy port as the Access URL. Is there a way
>>> to do this?
>>>
>>> In addition, if we are using kubernetes, one of the minion IPs can
>>> be(are) used as a load-balancer. In that case, how do we decide which IP to
>>> use? (say we have 3 minions and service can be accessed using any of the 3
>>> minion IPs : kubernetes service port)
>>>
>>>
>>> [1]
>>> https://cwiki.apache.org/confluence/display/STRATOS/4.0.0+Sample+Cartridge+Definition
>>> [2]
>>> https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Cartridge+Resource+Definition
>>> [3]
>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
>>>
>>> Thanks,
>>> --
>>> *Lasindu Charith*
>>> Software Engineer, WSO2 Inc.
>>> Committer & PMC Member, Apache Stratos
>>> Mobile: +94714427192 | Web: blog.lasindu.com
>>>
>>
>>
>>
>> --
>> Akila Ravihansa Perera
>> WSO2 Inc.;  http://wso2.com/
>>
>> Blog: http://ravihansa3000.blogspot.com
>>
>
>
> Thanks,
> --
> *Lasindu Charith*
> Software Engineer, WSO2 Inc.
> Committer & PMC Member, Apache Stratos
> Mobile: +94714427192 | Web: blog.lasindu.com
>



-- 
Imesh Gunaratne

Senior Technical Lead, WSO2
Committer & PMC Member, Apache Stratos

Re: How to incorporate a LB with a Stratos Application/Cartridge

Posted by Lasindu Charith <la...@wso2.com>.
Hi Akila

On Sun, Aug 16, 2015 at 11:32 AM, Akila Ravihansa Perera <ravihansa@wso2.com
> wrote:

> Hi Lasindu,
>
> I think your question is about using LB properties (IP, port, hostname)
> inside the cartridge instance. We can pass those parameters in the
> cartridge definition as payload parameters as a simple solution. We can
> also publish those information in meta-data service as well. Publishing to
> meta-data service will be more flexible since we can easily update those
> values without having to redeploy cartridges etc.
>
> Yes, this seems to be the simplest solution. but is it OK to generate an
access URL from Stratos, based on a custom parameter?
IMO, it would be better to have a separate section for LB similar to 4.0.0?


> Regarding Kubernetes scenario, we need to have an external LB which would
> forward requests to all the upstream minion instances. Then use that
> external LB within all pods (services can be differentiated through
> different hsotnames)
>
> Yes, this seems to be the better approach.


> This is just my suggestion. Perhaps there is a better way.
>
> Thanks.
>
> On Sun, Aug 16, 2015 at 8:05 AM, Lasindu Charith <la...@wso2.com> wrote:
>
>> Hi devs,
>>
>> Suppose I configured an external LB such as Nginx, HAproxy etc. Now I
>> need to use it in my Stratos application.
>>
>> Previously in 4.0.0 there was a LB property in Cartridge definition[1
>> <https://cwiki.apache.org/confluence/display/STRATOS/4.0.0+Sample+Cartridge+Definition>],
>> but seems like it's not there anymore in 4.1.0[2
>> <https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Cartridge+Resource+Definition>]
>> or in [3
>> <https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java>
>> ].
>>
>>     "loadBalancer":{
>>          "type":"lb",
>>          "property":{
>>             "name":"default.load.balancer",
>>             "value":"true"
>>          }
>>     }
>>
>> Some product configurations needs LB ip/port and in UI too we should show
>> the LB IP along with the proxy port as the Access URL. Is there a way to do
>> this?
>>
>> In addition, if we are using kubernetes, one of the minion IPs can
>> be(are) used as a load-balancer. In that case, how do we decide which IP to
>> use? (say we have 3 minions and service can be accessed using any of the 3
>> minion IPs : kubernetes service port)
>>
>>
>> [1]
>> https://cwiki.apache.org/confluence/display/STRATOS/4.0.0+Sample+Cartridge+Definition
>> [2]
>> https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Cartridge+Resource+Definition
>> [3]
>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
>>
>> Thanks,
>> --
>> *Lasindu Charith*
>> Software Engineer, WSO2 Inc.
>> Committer & PMC Member, Apache Stratos
>> Mobile: +94714427192 | Web: blog.lasindu.com
>>
>
>
>
> --
> Akila Ravihansa Perera
> WSO2 Inc.;  http://wso2.com/
>
> Blog: http://ravihansa3000.blogspot.com
>


Thanks,
-- 
*Lasindu Charith*
Software Engineer, WSO2 Inc.
Committer & PMC Member, Apache Stratos
Mobile: +94714427192 | Web: blog.lasindu.com

Re: How to incorporate a LB with a Stratos Application/Cartridge

Posted by Akila Ravihansa Perera <ra...@wso2.com>.
Hi Lasindu,

I think your question is about using LB properties (IP, port, hostname)
inside the cartridge instance. We can pass those parameters in the
cartridge definition as payload parameters as a simple solution. We can
also publish those information in meta-data service as well. Publishing to
meta-data service will be more flexible since we can easily update those
values without having to redeploy cartridges etc.

Regarding Kubernetes scenario, we need to have an external LB which would
forward requests to all the upstream minion instances. Then use that
external LB within all pods (services can be differentiated through
different hsotnames)

This is just my suggestion. Perhaps there is a better way.

Thanks.

On Sun, Aug 16, 2015 at 8:05 AM, Lasindu Charith <la...@wso2.com> wrote:

> Hi devs,
>
> Suppose I configured an external LB such as Nginx, HAproxy etc. Now I need
> to use it in my Stratos application.
>
> Previously in 4.0.0 there was a LB property in Cartridge definition[1
> <https://cwiki.apache.org/confluence/display/STRATOS/4.0.0+Sample+Cartridge+Definition>],
> but seems like it's not there anymore in 4.1.0[2
> <https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Cartridge+Resource+Definition>]
> or in [3
> <https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java>
> ].
>
>     "loadBalancer":{
>          "type":"lb",
>          "property":{
>             "name":"default.load.balancer",
>             "value":"true"
>          }
>     }
>
> Some product configurations needs LB ip/port and in UI too we should show
> the LB IP along with the proxy port as the Access URL. Is there a way to do
> this?
>
> In addition, if we are using kubernetes, one of the minion IPs can be(are)
> used as a load-balancer. In that case, how do we decide which IP to use?
> (say we have 3 minions and service can be accessed using any of the 3
> minion IPs : kubernetes service port)
>
>
> [1]
> https://cwiki.apache.org/confluence/display/STRATOS/4.0.0+Sample+Cartridge+Definition
> [2]
> https://cwiki.apache.org/confluence/display/STRATOS/4.1.0+Cartridge+Resource+Definition
> [3]
> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
>
> Thanks,
> --
> *Lasindu Charith*
> Software Engineer, WSO2 Inc.
> Committer & PMC Member, Apache Stratos
> Mobile: +94714427192 | Web: blog.lasindu.com
>



-- 
Akila Ravihansa Perera
WSO2 Inc.;  http://wso2.com/

Blog: http://ravihansa3000.blogspot.com