You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Imesh Gunaratne <im...@apache.org> on 2015/05/20 21:24:30 UTC

[Discuss] Specifying CPU and Memory in Docker Cartridges

Hi Devs,

I have now implemented support to specify CPU (number of cores) and Memory
(in MB) in Docker Cartridges. These values will be passed to Kubernetes
when creating a Pod and Kubernetes will limit those resources to containers
accordingly.

If CPU and Memory should not be restricted, above parameter values can be
set to zero. Please find a sample cartridge definition below:

{
    "type": "php",
    "provider": "apache",
    "category": "framework",
    "host": "php.stratos.org",
    "displayName": "php",
    "description": "php Cartridge",
    "version": "7",
    "multiTenant": "false",
    "loadBalancingIPType": "public",
    "portMapping": [
        {
            "protocol": "http",
            "port": "80",
            "proxyPort": "8281"
        }
    ],
    "deployment": {
        "baseDir": "/var/www"
    },
    "iaasProvider": [
        {
            "type": "kubernetes",
            "imageId": "stratos/php:4.1.0-beta",
            "networkInterfaces": [
            ],
            "property": [
            ]
        }
    ],
    "property": [
        {
            "name": "KUBERNETES_CONTAINER_CPU",
            "value": "1"
        },
        {
            "name": "KUBERNETES_CONTAINER_MEMORY",
            "value": "512"
        }
    ]
}

Thanks

-- 
Imesh Gunaratne

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

Re: [Discuss] Specifying CPU and Memory in Docker Cartridges

Posted by Imesh Gunaratne <im...@apache.org>.
Thanks for the feedback Raj! I think you made a good point, the defaults
should be set to zero to make them none restricted.
What I observed is that when we set these values the containers get more
time to start.

Thanks

On Thu, May 21, 2015 at 2:33 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> I went through the code and figured it out :-)
>
> If we don't specify these parameters, the default values will be cpu -> 1
> and ram-> 1024. I guess that should be the way to do it.
>
> Thanks.
>
> On Thu, May 21, 2015 at 2:14 AM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> This is great Imesh!
>>
>> If we don't specify these parameters, the CPU and Memory won't be
>> restricted right? Do we have to explicitly set these to 0?
>>
>> Thanks.
>>
>> On Thu, May 21, 2015 at 12:54 AM, Imesh Gunaratne <im...@apache.org>
>> wrote:
>>
>>> Hi Devs,
>>>
>>> I have now implemented support to specify CPU (number of cores) and
>>> Memory (in MB) in Docker Cartridges. These values will be passed to
>>> Kubernetes when creating a Pod and Kubernetes will limit those resources to
>>> containers accordingly.
>>>
>>> If CPU and Memory should not be restricted, above parameter values can
>>> be set to zero. Please find a sample cartridge definition below:
>>>
>>> {
>>>     "type": "php",
>>>     "provider": "apache",
>>>     "category": "framework",
>>>     "host": "php.stratos.org",
>>>     "displayName": "php",
>>>     "description": "php Cartridge",
>>>     "version": "7",
>>>     "multiTenant": "false",
>>>     "loadBalancingIPType": "public",
>>>     "portMapping": [
>>>         {
>>>             "protocol": "http",
>>>             "port": "80",
>>>             "proxyPort": "8281"
>>>         }
>>>     ],
>>>     "deployment": {
>>>         "baseDir": "/var/www"
>>>     },
>>>     "iaasProvider": [
>>>         {
>>>             "type": "kubernetes",
>>>             "imageId": "stratos/php:4.1.0-beta",
>>>             "networkInterfaces": [
>>>             ],
>>>             "property": [
>>>             ]
>>>         }
>>>     ],
>>>     "property": [
>>>         {
>>>             "name": "KUBERNETES_CONTAINER_CPU",
>>>             "value": "1"
>>>         },
>>>         {
>>>             "name": "KUBERNETES_CONTAINER_MEMORY",
>>>             "value": "512"
>>>         }
>>>     ]
>>> }
>>>
>>> Thanks
>>>
>>> --
>>> Imesh Gunaratne
>>>
>>> Senior Technical Lead, WSO2
>>> Committer & PMC Member, Apache Stratos
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>> Mobile : +94777568639
>> Blog : rajkumarr.com
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>
> Mobile : +94777568639
> Blog : rajkumarr.com
>



-- 
Imesh Gunaratne

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

Re: [Discuss] Specifying CPU and Memory in Docker Cartridges

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
I went through the code and figured it out :-)

If we don't specify these parameters, the default values will be cpu -> 1
and ram-> 1024. I guess that should be the way to do it.

Thanks.

On Thu, May 21, 2015 at 2:14 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> This is great Imesh!
>
> If we don't specify these parameters, the CPU and Memory won't be
> restricted right? Do we have to explicitly set these to 0?
>
> Thanks.
>
> On Thu, May 21, 2015 at 12:54 AM, Imesh Gunaratne <im...@apache.org>
> wrote:
>
>> Hi Devs,
>>
>> I have now implemented support to specify CPU (number of cores) and
>> Memory (in MB) in Docker Cartridges. These values will be passed to
>> Kubernetes when creating a Pod and Kubernetes will limit those resources to
>> containers accordingly.
>>
>> If CPU and Memory should not be restricted, above parameter values can be
>> set to zero. Please find a sample cartridge definition below:
>>
>> {
>>     "type": "php",
>>     "provider": "apache",
>>     "category": "framework",
>>     "host": "php.stratos.org",
>>     "displayName": "php",
>>     "description": "php Cartridge",
>>     "version": "7",
>>     "multiTenant": "false",
>>     "loadBalancingIPType": "public",
>>     "portMapping": [
>>         {
>>             "protocol": "http",
>>             "port": "80",
>>             "proxyPort": "8281"
>>         }
>>     ],
>>     "deployment": {
>>         "baseDir": "/var/www"
>>     },
>>     "iaasProvider": [
>>         {
>>             "type": "kubernetes",
>>             "imageId": "stratos/php:4.1.0-beta",
>>             "networkInterfaces": [
>>             ],
>>             "property": [
>>             ]
>>         }
>>     ],
>>     "property": [
>>         {
>>             "name": "KUBERNETES_CONTAINER_CPU",
>>             "value": "1"
>>         },
>>         {
>>             "name": "KUBERNETES_CONTAINER_MEMORY",
>>             "value": "512"
>>         }
>>     ]
>> }
>>
>> Thanks
>>
>> --
>> Imesh Gunaratne
>>
>> Senior Technical Lead, WSO2
>> Committer & PMC Member, Apache Stratos
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>
> Mobile : +94777568639
> Blog : rajkumarr.com
>



-- 
Rajkumar Rajaratnam
Committer & PMC Member, Apache Stratos
Software Engineer, WSO2

Mobile : +94777568639
Blog : rajkumarr.com

Re: [Discuss] Specifying CPU and Memory in Docker Cartridges

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
This is great Imesh!

If we don't specify these parameters, the CPU and Memory won't be
restricted right? Do we have to explicitly set these to 0?

Thanks.

On Thu, May 21, 2015 at 12:54 AM, Imesh Gunaratne <im...@apache.org> wrote:

> Hi Devs,
>
> I have now implemented support to specify CPU (number of cores) and Memory
> (in MB) in Docker Cartridges. These values will be passed to Kubernetes
> when creating a Pod and Kubernetes will limit those resources to containers
> accordingly.
>
> If CPU and Memory should not be restricted, above parameter values can be
> set to zero. Please find a sample cartridge definition below:
>
> {
>     "type": "php",
>     "provider": "apache",
>     "category": "framework",
>     "host": "php.stratos.org",
>     "displayName": "php",
>     "description": "php Cartridge",
>     "version": "7",
>     "multiTenant": "false",
>     "loadBalancingIPType": "public",
>     "portMapping": [
>         {
>             "protocol": "http",
>             "port": "80",
>             "proxyPort": "8281"
>         }
>     ],
>     "deployment": {
>         "baseDir": "/var/www"
>     },
>     "iaasProvider": [
>         {
>             "type": "kubernetes",
>             "imageId": "stratos/php:4.1.0-beta",
>             "networkInterfaces": [
>             ],
>             "property": [
>             ]
>         }
>     ],
>     "property": [
>         {
>             "name": "KUBERNETES_CONTAINER_CPU",
>             "value": "1"
>         },
>         {
>             "name": "KUBERNETES_CONTAINER_MEMORY",
>             "value": "512"
>         }
>     ]
> }
>
> Thanks
>
> --
> Imesh Gunaratne
>
> Senior Technical Lead, WSO2
> Committer & PMC Member, Apache Stratos
>



-- 
Rajkumar Rajaratnam
Committer & PMC Member, Apache Stratos
Software Engineer, WSO2

Mobile : +94777568639
Blog : rajkumarr.com