anchor.diff:  
   == Overview
   
  -A *ResourceQuota* object enumerates hard resource usage limits per project. It
  -limits the total number of a particular type of object that may be created in
  -a project, and the total amount of
  -link:compute_resources.html[compute resources]
  +A `ResourceQuota` defines constraints that limit aggregrate resource consumption
  +per project.  It can limit the quantity of objects that can be created in a project
  +by type, as well as the total amount of link:compute_resources.html[compute resources]
   that may be consumed by resources in that project.
   
  -== Usage Limits
  -
  -The following describes the set of limits that may be enforced by a
  -*ResourceQuota*.
  -
  -.Usage limits
  +== Resources managed by quota
  +
  +The following describes the set of resources that may be managed by a `ResourceQuota`.
  +
  +.Resources managed by quota
   [cols="3a,8a",options="header"]
   |===
   
   |Resource Name |Description
   
   |`cpu`
  -|Total requested cpu usage across all containers
  +|Across all pods in a non-terminal state, the sum of cpu requests cannot exceed this value.
   
   |`memory`
  -|Total requested memory usage across all containers
  -
  -|`openshift.io/imagesize` [[imagesize]]<<zero,*>>
  -|Maximum size of a single image stored in an internal registry
  -
  -|`openshift.io/imagestreamsize` [[imagestreamsize]]<<zero,*>>
  -|Maximum size of image stream's images stored in an internal registry
  -
  -|`openshift.io/projectimagessize`
  -|Maximum size of all the project's images stored in an internal registry
  +|Across all pods in a non-terminal state, the sum of memory requests cannot exceed this value.
  +
  +|`requests.cpu`
  +|Across all pods in a non-terminal state, the sum of cpu requests cannot exceed this value.
  +
  +|`requests.memory`
  +|Across all pods in a non-terminal state, the sum of memory requests cannot exceed this value.
  +
  +|`limits.cpu`
  +|Across all pods in a non-terminal state, the sum of cpu limits cannot exceed this value.
  +
  +|`limits.memory`
  +|Across all pods in a non-terminal state, the sum of memory limits cannot exceed this value.
  +
  +|`configmaps`
  +|The total number of config maps that can exist in the project.
   
   |`pods`
  -|Total number of pods
  +|The total number of pods in a non-terminal state that can exist in the project.  A pod is in a terminal state if `status.phase in (Failed, Succeeded)` is true.
   
   |`replicationcontrollers`
  -|Total number of replication controllers
  +|The total number of replication controllers that can exist in the project.
   
   |`resourcequotas`
  -|Total number of resource quotas
  +|The total number of resource quotas that can exist in the project.
   
   |`services`
  -|Total number of services
  +|The total number of services that can exist in the project.
   
   |`secrets`
  -|Total number of secrets
  +|The total number of secrets that can exist in the project.
   
   |`persistentvolumeclaims`
  -|Total number of persistent volume claims
  -|===
  -
  -[[zero]]<<imagesize,*>> The resource is not scoped to a project. Thus it will
  -always have usage equal to zero.
  +|The total number of persistent volume claims that can exist in the project.
  +|===
  +
  +== Quota Scopes
  +
  +Each quota can have an associated set of scopes.  A quota will only
  +measure usage for a resource if it matches the intersection of enumerated
  +scopes.
  +
  +Adding a scope to a quota limits the number of resources it supports
  +to those that pertain to the scope.  Specifying a resource on the quota outside
  +of the allowed set would result in a validation error.
  +
  +.Quota scopes
  +[cols="3a,8a",options="header"]
  +|===
  +
  +|Scope |Description
  +
  +|`Terminating`
  +|Match pods where `spec.activeDeadlineSeconds >= 0`
  +
  +|`NotTerminating`
  +|Match pods where `spec.activeDeadlineSeconds is nil`
  +
  +|`BestEffort`
  +|Match pods that have best effort quality of service for either `cpu` or `memory`.
  +
  +|`NotBestEffort`
  +|Match pods that do not have best effort quality of service for `cpu` and `memory`.
  +|===
  +
  +A `BestEffort` scope restricts a quota to limit the following resources:
  +
  +1. pods 
  +
  +A `Terminating`, `NotTerminating`, and `NotBestEffort` scope restricts a quota to tracking the following resources:
  +
  +1. `pods`
  +2. `memory`, `requests.memory`, `limits.memory`
  +3. `cpu`, `requests.cpu`, `limits.cpu`
   
   == Quota Enforcement
   
  
positive.code: --------                      ----    ----
  cpu                           5       20
  memory                        500Mi   1Gi
  openshift.io/imagesize        0       5Gi   <1>
  openshift.io/imagestreamsize  0       15Gi  <1>
  openshift.io/projectsize      8542Mi  40Gi
  pods                          5       10
  replicationcontrollers        5       5
  resourcequotas                1       1
  services                      3       5
  ----
  <1> Usage will always be zero because the resource is not scoped to a namespace.
  
  [[configuring_quota_sync_period]]
  
  
negative.code: 
  === Compute Resources: Requests vs Limits
  
  When allocating compute resources, each container may specify a request and a limit value
  for either CPU or memory.  The quota can be configured to quota either value.  If the quota
  has a value specified for `requests.cpu` or `requests.memory`, then it will require that 
  every incoming container makes an explicit request for those resources.  If the quota has a 
  value specified for `limits.cpu` or `limits.memory`, then it will require that every incoming
  container specifies an explicit limit for those resources.
  
  == Sample Resource Quota Files
  
  object-counts.yaml
  ====
  ----
  apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: object-counts
  spec:
    hard:
      configmaps: "10" <1>
      persistentvolumeclaims: "4" <2>
      replicationcontrollers: "20" <3>
      secrets: "10" <4>
      services: "10" <5>
  ----
  <1> The total number of config maps that can exist in the project
  <2> The total number of persistent volume claims that can exist in the project
  <3> The total number of replication controllers that can exist in the project
  <4> The total number of secrets that can exist in the project
  <5> The total number of services that can exist in the project
  ====
  
  compute-resources.yaml
  ====
  ----
  apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: compute-resources
  spec:
    hard:
      pods: "4" <1>
      requests.cpu: "1" <2>
      requests.memory: 1Gi <3>
      limits.cpu: "2" <4>
      limits.memory: 2Gi <5>
  ----
  <1> The total number of pods in a non-terminal state that can exist in the project
  <2> Across all pods in a non-terminal state, the sum of cpu requests cannot exceed 1 core
  <3> Across all pods in a non-terminal state, the sum of memory requests cannot exceed 1Gi
  <4> Across all pods in a non-terminal state, the sum of cpu limits cannot exceed 2 cores
  <5> Across all pods in a non-terminal state, the sum of memory limits cannot exceed 2Gi
  ====
  
  besteffort.yaml
  ====
  ----
  apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: besteffort
  spec:
    hard:
      pods: "1" <1>
    scopes:
    - BestEffort <2>
  ----
  <1> The total number of pods in a non-terminal state with `BestEffort` quality of service that can exist in the project
  <2> Restricts the quota to only matching pods that have `BestEffort` quality of service for either memory or cpu.
  ====
  
  == Create a Quota
  