mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Display extended resources in node allocated resources
This commit is contained in:
parent
c8841cea30
commit
bd02b49c20
@ -2979,8 +2979,9 @@ func describeNodeResource(nodeNonTerminatedPodsList *api.PodList, node *api.Node
|
||||
memoryReq.String(), int64(fractionMemoryReq), memoryLimit.String(), int64(fractionMemoryLimit))
|
||||
}
|
||||
|
||||
w.Write(LEVEL_0, "Allocated resources:\n (Total limits may be over 100 percent, i.e., overcommitted.)\n CPU Requests\tCPU Limits\tMemory Requests\tMemory Limits\n")
|
||||
w.Write(LEVEL_1, "------------\t----------\t---------------\t-------------\n")
|
||||
w.Write(LEVEL_0, "Allocated resources:\n (Total limits may be over 100 percent, i.e., overcommitted.)\n")
|
||||
w.Write(LEVEL_1, "Resource\tRequests\tLimits\n")
|
||||
w.Write(LEVEL_1, "--------\t--------\t------\n")
|
||||
reqs, limits := getPodsTotalRequestsAndLimits(nodeNonTerminatedPodsList)
|
||||
cpuReqs, cpuLimits, memoryReqs, memoryLimits := reqs[api.ResourceCPU], limits[api.ResourceCPU], reqs[api.ResourceMemory], limits[api.ResourceMemory]
|
||||
fractionCpuReqs := float64(0)
|
||||
@ -2995,9 +2996,21 @@ func describeNodeResource(nodeNonTerminatedPodsList *api.PodList, node *api.Node
|
||||
fractionMemoryReqs = float64(memoryReqs.Value()) / float64(allocatable.Memory().Value()) * 100
|
||||
fractionMemoryLimits = float64(memoryLimits.Value()) / float64(allocatable.Memory().Value()) * 100
|
||||
}
|
||||
w.Write(LEVEL_1, "%s (%d%%)\t%s (%d%%)\t%s (%d%%)\t%s (%d%%)\n",
|
||||
cpuReqs.String(), int64(fractionCpuReqs), cpuLimits.String(), int64(fractionCpuLimits),
|
||||
memoryReqs.String(), int64(fractionMemoryReqs), memoryLimits.String(), int64(fractionMemoryLimits))
|
||||
w.Write(LEVEL_1, "%s\t%s (%d%%)\t%s (%d%%)\n",
|
||||
api.ResourceCPU, cpuReqs.String(), int64(fractionCpuReqs), cpuLimits.String(), int64(fractionCpuLimits))
|
||||
w.Write(LEVEL_1, "%s\t%s (%d%%)\t%s (%d%%)\n",
|
||||
api.ResourceMemory, memoryReqs.String(), int64(fractionMemoryReqs), memoryLimits.String(), int64(fractionMemoryLimits))
|
||||
extResources := make([]string, 0, len(allocatable))
|
||||
for resource := range allocatable {
|
||||
if !helper.IsStandardContainerResourceName(string(resource)) && resource != api.ResourcePods {
|
||||
extResources = append(extResources, string(resource))
|
||||
}
|
||||
}
|
||||
sort.Strings(extResources)
|
||||
for _, ext := range extResources {
|
||||
extRequests, extLimits := reqs[api.ResourceName(ext)], limits[api.ResourceName(ext)]
|
||||
w.Write(LEVEL_1, "%s\t%s\t%s\n", ext, extRequests.String(), extLimits.String())
|
||||
}
|
||||
}
|
||||
|
||||
func getPodsTotalRequestsAndLimits(podList *api.PodList) (reqs map[api.ResourceName]resource.Quantity, limits map[api.ResourceName]resource.Quantity) {
|
||||
|
Loading…
Reference in New Issue
Block a user