Introduction
Quotas are a way of restricting resource usage by Nomad jobs. This is an Enterprise Only feature.
Assigning a quota to a namespace means limiting the number of resources the jobs in a namespace can utilize.
All quotas must be assigned to a namespace to come into effect.
Jobs outside a namespace cannot be controlled by in-namespace quotas
While Quota commands allow you to witness various quota information, they do not show the breakdown of the job-wise quotas .
This is a quick fire way to that.
Command
nomad job status --namespace=<your_quota_name> | awk 'NR>1 {print $1}' | grep -v "^ID" | xargs -I {} nomad job inspect --namespace=<your_namespace_name> {} | jq '.Job.TaskGroups[] | {Count: .Count, Memory: .Tasks[0].Resources.MemoryMB, CPU: .Tasks[0].Resources.CPU}'
Sample output
* Two jobs running in a namespace
nomad job status
ID Type Priority Status Submit Date
abc service 50 running 2024-03-11T19:12:52-04:00
example service 50 running 2024-03-11T13:44:32-04:00
* Listing the Quota information shows a total of 1100 CPU being utilized
nomad quota status QUOTA
Name = QUOTA
Description = Quota for TestQuota namespace
Limits = 1
Quota Limits
Region CPU Usage Memory Usage Memory Max Usage Variables Usage
global 1100 / 2500 512 / 1000 512 / 1000 0 / 1000
* However we see that job `abc` and `example` have values of CPU as 500 and 600 respectively.
nomad job status --namespace=testquota | awk 'NR>1 {print $1}' | grep -v "^ID" | xargs -I {} nomad job inspect --namespace=testquota {} | jq '.Job.TaskGroups[] | {Count: .Count, Memory: .Tasks[0].Resources.MemoryMB, CPU: .Tasks[0].Resources.CPU}'
{
"Count": 1,
"Memory": 256,
"CPU": 600
}
{
"Count": 1,
"Memory": 256,
"CPU": 500
}