Adding ResourceRequirementSpec to v1beta1, v1beta2, and v1beta3 APIs. The old resource

quantities 'CPU' and 'Memory' will be preserved until support for v1beta1 and v1beta2 APIs are
dropped.
Improved resource validation in the process.
This commit is contained in:
Vishnu Kannan
2015-01-25 04:19:36 +00:00
parent aa3b45d17b
commit 5e36f63f8b
23 changed files with 782 additions and 175 deletions

View File

@@ -179,7 +179,7 @@ func (rm *ResourceQuotaManager) syncResourceQuota(quota api.ResourceQuota) (err
func PodCPU(pod *api.Pod) *resource.Quantity {
val := int64(0)
for j := range pod.Spec.Containers {
val = val + pod.Spec.Containers[j].CPU.MilliValue()
val = val + pod.Spec.Containers[j].Resources.Limits.Cpu().MilliValue()
}
return resource.NewMilliQuantity(int64(val), resource.DecimalSI)
}
@@ -188,7 +188,7 @@ func PodCPU(pod *api.Pod) *resource.Quantity {
func PodMemory(pod *api.Pod) *resource.Quantity {
val := int64(0)
for j := range pod.Spec.Containers {
val = val + pod.Spec.Containers[j].Memory.Value()
val = val + pod.Spec.Containers[j].Resources.Limits.Memory().Value()
}
return resource.NewQuantity(int64(val), resource.DecimalSI)
}