open-nomad/website/content/api-docs/quotas.mdx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

355 lines
8.6 KiB
Plaintext
Raw Normal View History

2017-10-13 21:02:30 +00:00
---
layout: api
2017-10-15 23:41:24 +00:00
page_title: Quotas - HTTP API
2020-02-06 23:45:31 +00:00
description: The /quota endpoints are used to query for and interact with quotas.
2017-10-13 21:02:30 +00:00
---
2017-10-15 23:41:24 +00:00
# Quota HTTP API
2017-10-13 21:02:30 +00:00
2017-10-15 23:41:24 +00:00
The `/quota` endpoints are used to query for and interact with quotas.
2017-10-13 21:02:30 +00:00
<EnterpriseAlert>
This API endpoint and functionality only exists in Nomad Enterprise. This is
not present in the open source version of Nomad.
</EnterpriseAlert>
2017-10-13 21:02:30 +00:00
2017-10-15 23:41:24 +00:00
## List Quota Specifications
2017-10-13 21:02:30 +00:00
2017-10-15 23:41:24 +00:00
This endpoint lists all quota specifications.
2017-10-13 21:02:30 +00:00
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------ | ------------------ |
| `GET` | `/v1/quotas` | `application/json` |
2017-10-13 21:02:30 +00:00
The table below shows this endpoint's support for
[blocking queries](/nomad/api-docs#blocking-queries) and
[required ACLs](/nomad/api-docs#acls).
2017-10-13 21:02:30 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | --------------------------------------------------------------- |
| `YES` | `quota:read`<br />`namespace:*` if namespace has quota attached |
2017-10-13 21:02:30 +00:00
### Parameters
2017-10-15 23:41:24 +00:00
- `prefix` `(string: "")`- Specifies a string to filter quota specifications on
2019-05-08 19:14:31 +00:00
based on an index prefix. This is specified as a query string parameter.
2017-10-13 21:02:30 +00:00
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/quotas
2017-10-13 21:02:30 +00:00
```
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/quotas?prefix=sha
2017-10-13 21:02:30 +00:00
```
### Sample Response
```json
[
2017-10-15 23:41:24 +00:00
{
"CreateIndex": 8,
"Description": "Limit the shared default namespace",
"Hash": "SgDCH7L5ZDqNSi2NmJlqdvczt/Q6mjyVwVJC0XjWglQ=",
"Limits": [
{
"Hash": "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=",
"Region": "global",
"RegionLimit": {
"CPU": 2500,
"DiskMB": 0,
"MemoryMB": 2000,
"Networks": [
{
"CIDR": "",
"Device": "",
"DynamicPorts": null,
"IP": "",
"MBits": 50,
"Mode": "",
"ReservedPorts": null
}
]
},
"VariablesLimit": 1000
2017-10-15 23:41:24 +00:00
}
],
"ModifyIndex": 56,
"Name": "shared-quota"
}
2017-10-13 21:02:30 +00:00
]
```
2017-10-15 23:41:24 +00:00
## Read Quota Specification
2017-10-13 21:02:30 +00:00
2017-10-15 23:41:24 +00:00
This endpoint reads information about a specific quota specification.
2017-10-13 21:02:30 +00:00
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------------ | ------------------ |
| `GET` | `/v1/quota/:quota` | `application/json` |
2017-10-13 21:02:30 +00:00
The table below shows this endpoint's support for
[blocking queries](/nomad/api-docs#blocking-queries) and
[required ACLs](/nomad/api-docs#acls).
2017-10-13 21:02:30 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | --------------------------------------------------------------- |
| `YES` | `quota:read`<br />`namespace:*` if namespace has quota attached |
2017-10-13 21:02:30 +00:00
### Parameters
2017-10-16 19:40:41 +00:00
- `:quota` `(string: <required>)`- Specifies the quota specification to query
where the identifier is the quota's name.
2017-10-13 21:02:30 +00:00
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/quota/shared-quota
2017-10-13 21:02:30 +00:00
```
### Sample Response
```json
{
2017-10-15 23:41:24 +00:00
"CreateIndex": 8,
"Description": "Limit the shared default namespace",
"Hash": "SgDCH7L5ZDqNSi2NmJlqdvczt/Q6mjyVwVJC0XjWglQ=",
"Limits": [
{
"Hash": "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=",
"Region": "global",
"RegionLimit": {
"CPU": 2500,
"DiskMB": 0,
"MemoryMB": 2000,
"Networks": [
{
"CIDR": "",
"Device": "",
"DynamicPorts": null,
"IP": "",
"MBits": 50,
"Mode": "",
"ReservedPorts": null
}
]
},
"VariablesLimit": 1000
2017-10-15 23:41:24 +00:00
}
],
"ModifyIndex": 56,
"Name": "shared-quota"
2017-10-13 21:02:30 +00:00
}
```
2017-10-15 23:41:24 +00:00
## Create or Update Quota Specification
2017-10-13 21:02:30 +00:00
2017-10-15 23:41:24 +00:00
This endpoint is used to create or update a quota specification.
2017-10-13 21:02:30 +00:00
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------------------------------- | ------------------ |
| `POST` | `/v1/quota/:quota` <br /> `/v1/quota` | `application/json` |
2017-10-13 21:02:30 +00:00
The table below shows this endpoint's support for
[blocking queries](/nomad/api-docs#blocking-queries) and
[required ACLs](/nomad/api-docs#acls).
2017-10-13 21:02:30 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | ------------- |
2017-10-15 23:41:24 +00:00
| `NO` | `quota:write` |
2017-10-13 21:02:30 +00:00
2017-10-16 04:15:14 +00:00
### Body
2017-10-13 21:02:30 +00:00
2017-10-16 04:15:14 +00:00
The request body contains a valid, JSON quota specification. View the api
package to see the definition of a [`QuotaSpec`
object](https://pkg.go.dev/github.com/hashicorp/nomad/api#QuotaSpec).
2017-10-13 21:02:30 +00:00
### Sample Payload
```javascript
{
2017-10-16 04:15:14 +00:00
"Name": "shared-quota",
"Description": "Limit the shared default namespace",
"Limits": [
{
"Region": "global",
"RegionLimit": {
"CPU": 2500,
"MemoryMB": 1000,
"Networks": [
{
"Mbits": 50
}
]
2017-10-16 04:15:14 +00:00
}
}
]
2017-10-13 21:02:30 +00:00
}
```
2017-10-13 21:02:30 +00:00
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
2017-10-13 21:02:30 +00:00
--request POST \
2017-10-16 04:15:14 +00:00
--data @spec.json \
https://localhost:4646/v1/quota/shared-quota
2017-10-13 21:02:30 +00:00
```
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
2017-10-13 21:02:30 +00:00
--request POST \
2017-10-16 04:15:14 +00:00
--data @spec.json \
https://localhost:4646/v1/quota
2017-10-13 21:02:30 +00:00
```
2017-10-16 04:15:14 +00:00
## Delete Quota Specification
2017-10-13 21:02:30 +00:00
2017-10-16 04:15:14 +00:00
This endpoint is used to delete a quota specification.
2017-10-13 21:02:30 +00:00
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| -------- | ------------------ | ------------------ |
| `DELETE` | `/v1/quota/:quota` | `application/json` |
2017-10-13 21:02:30 +00:00
The table below shows this endpoint's support for
[blocking queries](/nomad/api-docs#blocking-queries) and
[required ACLs](/nomad/api-docs#acls).
2017-10-13 21:02:30 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | ------------- |
2017-10-16 04:15:14 +00:00
| `NO` | `quota:write` |
2017-10-13 21:02:30 +00:00
### Parameters
2017-10-16 19:40:41 +00:00
- `:quota` `(string: <required>)`- Specifies the quota specification to delete
where the identifier is the quota's name.
2017-10-13 21:02:30 +00:00
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
2017-10-13 21:02:30 +00:00
--request DELETE \
https://localhost:4646/v1/quota/shared-quota
2017-10-16 04:15:14 +00:00
```
## List Quota Usages
This endpoint lists all quota usages.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------------ | ------------------ |
| `GET` | `/v1/quota-usages` | `application/json` |
2017-10-16 04:15:14 +00:00
The table below shows this endpoint's support for
[blocking queries](/nomad/api-docs#blocking-queries) and
[required ACLs](/nomad/api-docs#acls).
2017-10-16 04:15:14 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | --------------------------------------------------------------- |
| `YES` | `quota:read`<br />`namespace:*` if namespace has quota attached |
2017-10-16 04:15:14 +00:00
### Parameters
- `prefix` `(string: "")`- Specifies a string to filter quota specifications on
2019-05-08 19:14:31 +00:00
based on an index prefix. This is specified as a query string parameter.
2017-10-16 04:15:14 +00:00
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/quota-usages
2017-10-16 04:15:14 +00:00
```
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/quota-usages?prefix=sha
2017-10-16 04:15:14 +00:00
```
### Sample Response
```json
[
{
"Used": {
"NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=": {
"Region": "global",
"RegionLimit": {
"CPU": 500,
"MemoryMB": 256,
"DiskMB": 0,
"Networks": null
},
"Hash": "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU="
}
},
"Name": "default",
"CreateIndex": 8,
"ModifyIndex": 56
}
]
```
## Read Quota Usage
This endpoint reads information about a specific quota usage.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------------------ | ------------------ |
| `GET` | `/v1/quota/usage/:quota` | `application/json` |
2017-10-16 04:15:14 +00:00
The table below shows this endpoint's support for
[blocking queries](/nomad/api-docs#blocking-queries) and
[required ACLs](/nomad/api-docs#acls).
2017-10-16 04:15:14 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | --------------------------------------------------------------- |
| `YES` | `quota:read`<br />`namespace:*` if namespace has quota attached |
2017-10-16 04:15:14 +00:00
### Parameters
2017-10-16 19:40:41 +00:00
- `:quota` `(string: <required>)`- Specifies the quota specification to query
where the identifier is the quota's name.
2017-10-16 04:15:14 +00:00
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/quota/usage/shared-quota
2017-10-16 04:15:14 +00:00
```
### Sample Response
```json
{
"Used": {
"NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU=": {
"Region": "global",
"RegionLimit": {
"CPU": 500,
"MemoryMB": 256,
"DiskMB": 0,
"Networks": [
{
"CIDR": "",
"Device": "",
"DynamicPorts": null,
"IP": "",
"MBits": 50,
"Mode": "",
"ReservedPorts": null
}
]
2017-10-16 04:15:14 +00:00
},
"Hash": "NLOoV2WBU8ieJIrYXXx8NRb5C2xU61pVVWRDLEIMxlU="
}
},
"Name": "default",
"CreateIndex": 8,
"ModifyIndex": 56
}
2017-10-13 21:02:30 +00:00
```