mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-01 22:03:54 +00:00
Add utility for determining qos of a pod
This commit is contained in:
@@ -18,6 +18,7 @@ package util
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -46,6 +47,25 @@ func isResourceBestEffort(container *api.Container, resource api.ResourceName) b
|
||||
return !hasReq || req.Value() == 0
|
||||
}
|
||||
|
||||
// GetPodQos returns the QoS class of a pod.
|
||||
// The QoS class of a pod is the lowest QoS class for each resource in each container.
|
||||
func GetPodQos(pod *api.Pod) string {
|
||||
qosValues := sets.NewString()
|
||||
for _, container := range pod.Spec.Containers {
|
||||
qosPerResource := GetQoS(&container)
|
||||
for _, qosValue := range qosPerResource {
|
||||
qosValues.Insert(qosValue)
|
||||
}
|
||||
}
|
||||
if qosValues.Has(BestEffort) {
|
||||
return BestEffort
|
||||
}
|
||||
if qosValues.Has(Burstable) {
|
||||
return Burstable
|
||||
}
|
||||
return Guaranteed
|
||||
}
|
||||
|
||||
// GetQos returns a mapping of resource name to QoS class of a container
|
||||
func GetQoS(container *api.Container) map[api.ResourceName]string {
|
||||
resourceToQoS := map[api.ResourceName]string{}
|
||||
|
||||
Reference in New Issue
Block a user