diff --git a/pkg/kubectl/util/qos/BUILD b/pkg/kubectl/util/qos/BUILD index baa609dae9..bed95210fc 100644 --- a/pkg/kubectl/util/qos/BUILD +++ b/pkg/kubectl/util/qos/BUILD @@ -6,7 +6,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/kubectl/util/qos", visibility = ["//visibility:public"], deps = [ - "//pkg/apis/core:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", diff --git a/pkg/kubectl/util/qos/qos.go b/pkg/kubectl/util/qos/qos.go index 4e0d06ca01..73b25acac2 100644 --- a/pkg/kubectl/util/qos/qos.go +++ b/pkg/kubectl/util/qos/qos.go @@ -17,15 +17,14 @@ limitations under the License. package qos import ( - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/kubernetes/pkg/apis/core" ) -var supportedQoSComputeResources = sets.NewString(string(core.ResourceCPU), string(core.ResourceMemory)) +var supportedQoSComputeResources = sets.NewString(string(corev1.ResourceCPU), string(corev1.ResourceMemory)) -func isSupportedQoSComputeResource(name v1.ResourceName) bool { +func isSupportedQoSComputeResource(name corev1.ResourceName) bool { return supportedQoSComputeResources.Has(string(name)) } @@ -33,9 +32,9 @@ func isSupportedQoSComputeResource(name v1.ResourceName) bool { // A pod is besteffort if none of its containers have specified any requests or limits. // A pod is guaranteed only when requests and limits are specified for all the containers and they are equal. // A pod is burstable if limits and requests do not match across all containers. -func GetPodQOS(pod *v1.Pod) v1.PodQOSClass { - requests := v1.ResourceList{} - limits := v1.ResourceList{} +func GetPodQOS(pod *corev1.Pod) corev1.PodQOSClass { + requests := corev1.ResourceList{} + limits := corev1.ResourceList{} zeroQuantity := resource.MustParse("0") isGuaranteed := true for _, container := range pod.Spec.Containers { @@ -72,12 +71,12 @@ func GetPodQOS(pod *v1.Pod) v1.PodQOSClass { } } - if !qosLimitsFound.HasAll(string(v1.ResourceMemory), string(v1.ResourceCPU)) { + if !qosLimitsFound.HasAll(string(corev1.ResourceMemory), string(corev1.ResourceCPU)) { isGuaranteed = false } } if len(requests) == 0 && len(limits) == 0 { - return v1.PodQOSBestEffort + return corev1.PodQOSBestEffort } // Check is requests match limits for all resources. if isGuaranteed { @@ -90,7 +89,7 @@ func GetPodQOS(pod *v1.Pod) v1.PodQOSClass { } if isGuaranteed && len(requests) == len(limits) { - return v1.PodQOSGuaranteed + return corev1.PodQOSGuaranteed } - return v1.PodQOSBurstable + return corev1.PodQOSBurstable } diff --git a/pkg/kubectl/util/resource/resource.go b/pkg/kubectl/util/resource/resource.go index e1b7fe4e4c..0a6f177a64 100644 --- a/pkg/kubectl/util/resource/resource.go +++ b/pkg/kubectl/util/resource/resource.go @@ -22,15 +22,15 @@ import ( "strconv" "strings" - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/sets" ) // PodRequestsAndLimits returns a dictionary of all defined resources summed up for all // containers of the pod. -func PodRequestsAndLimits(pod *v1.Pod) (reqs, limits v1.ResourceList) { - reqs, limits = v1.ResourceList{}, v1.ResourceList{} +func PodRequestsAndLimits(pod *corev1.Pod) (reqs, limits corev1.ResourceList) { + reqs, limits = corev1.ResourceList{}, corev1.ResourceList{} for _, container := range pod.Spec.Containers { addResourceList(reqs, container.Resources.Requests) addResourceList(limits, container.Resources.Limits) @@ -44,7 +44,7 @@ func PodRequestsAndLimits(pod *v1.Pod) (reqs, limits v1.ResourceList) { } // addResourceList adds the resources in newList to list -func addResourceList(list, new v1.ResourceList) { +func addResourceList(list, new corev1.ResourceList) { for name, quantity := range new { if value, ok := list[name]; !ok { list[name] = *quantity.Copy() @@ -57,7 +57,7 @@ func addResourceList(list, new v1.ResourceList) { // maxResourceList sets list to the greater of list/newList for every resource // either list -func maxResourceList(list, new v1.ResourceList) { +func maxResourceList(list, new corev1.ResourceList) { for name, quantity := range new { if value, ok := list[name]; !ok { list[name] = *quantity.Copy() @@ -72,7 +72,7 @@ func maxResourceList(list, new v1.ResourceList) { // ExtractContainerResourceValue extracts the value of a resource // in an already known container -func ExtractContainerResourceValue(fs *v1.ResourceFieldSelector, container *v1.Container) (string, error) { +func ExtractContainerResourceValue(fs *corev1.ResourceFieldSelector, container *corev1.Container) (string, error) { divisor := resource.Quantity{} if divisor.Cmp(fs.Divisor) == 0 { divisor = resource.MustParse("1") @@ -120,19 +120,19 @@ func convertResourceEphemeralStorageToString(ephemeralStorage *resource.Quantity } var standardContainerResources = sets.NewString( - string(v1.ResourceCPU), - string(v1.ResourceMemory), - string(v1.ResourceEphemeralStorage), + string(corev1.ResourceCPU), + string(corev1.ResourceMemory), + string(corev1.ResourceEphemeralStorage), ) // IsStandardContainerResourceName returns true if the container can make a resource request // for the specified resource func IsStandardContainerResourceName(str string) bool { - return standardContainerResources.Has(str) || IsHugePageResourceName(v1.ResourceName(str)) + return standardContainerResources.Has(str) || IsHugePageResourceName(corev1.ResourceName(str)) } // IsHugePageResourceName returns true if the resource name has the huge page // resource prefix. -func IsHugePageResourceName(name v1.ResourceName) bool { - return strings.HasPrefix(string(name), v1.ResourceHugePagesPrefix) +func IsHugePageResourceName(name corev1.ResourceName) bool { + return strings.HasPrefix(string(name), corev1.ResourceHugePagesPrefix) }