Changing quota definitions
Recently I’ve had several customers ask about whether quota definitions can be changed, both in the OSS product and in PCF. The short answer is “yes”. Here’s the longer:
First, for those of you who might be unfamiliar with quotas, they are assigned to organizations and basically limit consumption within that organization. A quota definition sets limits in certain areas, such as memory, number of service instances and so on. The Cloud Foundry deployment has any number of named quota definitions defined, and an organization is assigned a single quota_definition.
Viewing the defined quota_definitions
Currently the quota definitions for your elastic runtime deployment are only viewable through the command line client. As you surely know, we currently have two clis, the old (v5), which I will henceforth refer to as “cf” or v5, and the new (v6), which I will henceforth refer to as “gcf” or v6. To see the list of quota_defitions you can use the following commands:
cf -t set-quota
That is, execute the command with no arguments and you will first be shown a list of the available quota definitions.
Or with the new cli, first set the env variable CF_TRACE=true and execute:
gcf quotas
In both of the above cases we’ve run with tracing turned on so that you can see the details of the quota definitions. This will be key as you will need to know the format and key names when issuing curl commands described below.
Setting org quotas
Given existing quota definitions, assigning one to an organization is done very simply with the following (v5 and v6) CLI commands:
cf set-quota --organization myorg --quota-definition trial
or
gcf set-quota myorg trial
The final argument in each of these is the name of an existing quota definition.
Creating, deleting or updating quota definitions
Quota definitions themselves are created one of two ways; either at the time that you are deploying the elastic runtime, and/or post deployment, using the api.
At deployment time
This is done by simply including quota definitions in your deployment manifest properties, for example:
properties: quota_definitions: free: memory_limit: 0 total_services: 0 paid: memory_limit: 10240 total_services: -1 runaway: memory_limit: 102400 total_services: -1
PCF does not yet expose quota definitions in the Operations Manager (deployer), however, the good news is that regardless of how you deploy the Elastic Runtime, you may edit the quota definitions to your heart’s content after deployment.
Post deployment
To create a new quota definition using the API you simply need to issue a POST to the quota_definitions resource. The simplest way to do this is with the (v5) cf curl
command, as this will include your current token (obtained with a cf login) in the request; if you wish to use your favorite REST client you will have to futz with the auth token yourself. Note that v6 does not yet (!) support gcf curl
.
To craft the appropriate request you will need:
- The method: POST
- The relative path of the resource:
/v2/quota_definitions
- The body which will contain the details of the new quota definition:
{"name": "default2", "non_basic_services_allowed": true, "total_services": 100, "total_routes": 1000, "memory_limit": 10240, "trial_db_allowed": true}
Putting it all together, the request looks like this:
> cf curl POST /v2/quota_definitions -b '{"name": "default2", "non_basic_services_allowed": true, "total_services": 100, "total_routes": 1000, "memory_limit": 10240, "trial_db_allowed": true}'
And, voila!, you have your new quota definition. Go ahead and check.
Updating an existing quota definition is just as easy. Recall from above that you can use v5 or v6 commands to get a list of the current quota definitions, with the details by having tracing turned on. You need to find the relative path of the specific quota definition resource by looking at those details. Then craft the appropriate request:
- The method: PUT
- That relative path:
/v2/quota_definitions/286b4253-95de-442e-a2e8-d111c2adb2e2
- The body; simply include the properties you wish to change:
{"memory_limit": 20480}
Putting it all together, the request looks like this:
> cf curl PUT /v2/quota_definitions/286b4253-95de-442e-a2e8-d111c2adb2e2 -b '{"memory_limit": 20480}'
In response you will get the updated quota definition:
{ "metadata": { "guid": "286b4253-95de-442e-a2e8-d111c2adb2e2", "url": "/v2/quota_definitions/286b4253-95de-442e-a2e8-d111c2adb2e2", "created_at": "2014-01-14T19:26:43+00:00", "updated_at": "2014-01-14T19:28:43+00:00" }, "entity": { "name": "default", "non_basic_services_allowed": true, "total_services": 100, "total_routes": 1000, "memory_limit": 20480, "trial_db_allowed": true } }
We are planning to add cli commands to facilitate this (stories: here, here, here and here), and are adding these capabilities to PCF Operations Manager, but in the mean time you have at least this level of control.
And one more note – we are just about to officially release the v6 cli (it’s been in beta) at which point we will rename it to “cf” – so just to keep you on your toes, in my next post on the subject, the new will be v6 and called “cf”. 😉
Share Your Thoughts