etopeter / kubectl-view-utilization Goto Github PK
View Code? Open in Web Editor NEWkubectl plugin to show cluster CPU and Memory requests utilization
License: Apache License 2.0
kubectl plugin to show cluster CPU and Memory requests utilization
License: Apache License 2.0
Please allow for JSON output since it's easier for machines to parse.
Just an example, instead of:
cores 118 / 204 (58%)
memory 70G / 408G (17%)
Maybe this (units in millicores and bytes, respectively):
{
"cores": {
"requested": 118000,
"allocatable": 204000
},
"memory": {
"requested": 73400320,
"allocatable": 427819008
}
}
Describe the bug
A clear and concise description of what the bug is.
-h
doesnt work for the allocatable field.
kubectl view-utilization -h -o json | jq .CPU.allocatable
"590100"
kubectl view-utilization -o json | jq .CPU.allocatable
590100
System details
kubectl version
v0.3.3
kubectl view-utilization -v
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-26T21:54:15Z", GoVersion:"go1.15", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"17+", GitVersion:"v1.17.6-1+a8884f7132317c", GitCommit:"a8884f7132317cb20416de61547de1bcc11f0756", GitTreeState:"clean", BuildDate:"2020-07-24T02:22:06Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Describe the bug
Kubectl plugin naming conventions dictates that anything hyphen-separated is a subcommand so kubectl-view-utilization should be called like kubectl view utilization
and not kubectl view-utilization
.
sh-4.2# kubectl plugin list
The following compatible plugins are available:
/usr/local/bin/kubectl-grep
/usr/local/bin/kubectl-ingress_nginx
/usr/local/bin/kubectl-view-utilization
sh-4.2# kubectl-view-utilization -v
v0.3.2
sh-4.2# kubectl view utilization
The connection to the server localhost:8080 was refused - did you specify the right host or port?
The connection to the server localhost:8080 was refused - did you specify the right host or port?
Resource Requests %Requests Limits %Limits Allocatable Schedulable Free
CPU Err Err 0 0
Memory 0 Err Err 0 0 0
sh-4.2# kubectl view-utilization
Error: unknown command "view-utilization" for "kubectl"
Run 'kubectl --help' for usage.
sh-4.2#
System details
kubectl version
kubectl view-utilization -v
kubectl view-utilization -v
is precisely what doesn't work :) but its v0.3.2
Hello!
Please, add binary for Apple Silicone platform (darwin arm64)
Add option to show utilization of resources broken down by nodes just like namespaces.
Make plugin behave just like --no-headers flag removes headers from kubectl output.
Describe the bug
kubectl view-utilization nodes
command not returning correct values for CPU Request for nodes
System details
Big Sur 11.4
kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:52:14Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.11+IKS", GitCommit:"f9c13a7b4d87e89ac8abb7a30230f4c3d9272184", GitTreeState:"clean", BuildDate:"2021-05-14T21:38:40Z", GoVersion:"go1.15.12", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.21) and server (1.19) exceeds the supported minor version skew of +/-1
kubectl view-utilization -v
-> v0.3.3
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 15625m (98%) 72450m (456%)
memory 17270643072 (28%) 84819714816 (137%)
Above Result from describe node.
kubectl view-utilization nodes
CPU Memory
Node Requests %Requests Limits %Limits Requests %Requests Limits %Limits
10.176.15.179 4530 28 71900 452 17242783744 27 84724940800 137
describe and view-utilization not matching
Thanks for contributing this, it's super useful!
It would be nice to be able to get output filtered by node role (label "kubernetes.io/role=node"), or maybe arbitrary labels. Generally we don't run a lot of stuff on our masters, for example, so I'm more interested in seeing just the utilization on worker nodes.
Thoughts?
Steps to reproduce:
watch kubectl-view-utilization
kubectl drain
some nodesI think this might be a flaw in kubernetes itself but maybe there is a workaround?
Describe the bug
The columns for Schedulable and Free for memory seem to always be 0 for me, and also if I add a node label selector or if I the percent calculations for memory also mess up.
kubectl view-utilization
Resource Requests %Requests Limits %Limits Allocatable Schedulable Free
CPU 159606 55 153587 53 288288 128682 128682
Memory 248603738112 112 249245466624 112 220657360896 0 0
kubectl view-utilization -l role=kube-worker
Resource Requests %Requests Limits %Limits Allocatable Schedulable Free
CPU 152232 84 144281 80 180180 27948 27948
Memory 244533166080 Err 245171748864 Err 0 0 0
I looked into the source and didn't find anything wrong with the way the selector flag is being used, so then I looked at my nodes with kubectl describe node
. Here is the Capacity and Allocatable of one of the nodes with the role=kube-worker
label:
Capacity:
attachable-volumes-aws-ebs: 25
cpu: 16
ephemeral-storage: 65989144Ki
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 31842064Ki
pods: 110
Allocatable:
attachable-volumes-aws-ebs: 25
cpu: 12
ephemeral-storage: 35239910145
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 26902655374
pods: 110
Meanwhile here is a node without that label:
Capacity:
attachable-volumes-aws-ebs: 25
cpu: 36
ephemeral-storage: 16447336Ki
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 71930968Ki
pods: 110
Allocatable:
attachable-volumes-aws-ebs: 25
cpu: 36
ephemeral-storage: 15157864833
hugepages-1Gi: 0
hugepages-2Mi: 0
memory: 71828568Ki
pods: 110
As you can see the units for memory are consistent for the node without the label. For the node with the label they're not (kibibytes versus bytes.)
I think the problem, at least when I provide the selector, is that the units don't match for the first node. Though I am not sure why Schedulable and Free have the issue of being always 0.
Semi-related issue (my units are different but it seems that the root cause of the units being inconsistent is the same as this issue): kubernetes/kubernetes#74986
System details
kubectl version
: 1.17.8kubectl view-utilization -v
: v0.3.2Graphical representation of utilization. We could use ASCII characters to represent node. Optional colors could be also used to represent intensity.
👋 Hello, maintainer of the kubectl plugin manager krew here.
Thank you for your commitment to open source by making this plugin available via krew
!
Krew wants to give credit where credit is due by installing the proper license file for the plugins it distributes. However, your plugin was found to not contain any license file. We wanted to remind you that if you're using a license such as Apache 2.0, you should be bundling your LICENSE file with your plugin’s distributions.
What do you have to do?
files:
section to copy the file to the installation directory. Have a look at this PR for an example: https://github.com/kubernetes-sigs/krew-index/pull/314/filesIf you need further assistance, don't hesitate to ask for help.
Describe the bug
I'm probably doing something wrong, but wanted to clarify why I could be getting the following output:
❯ kubectl view-utilization
Resource Requests %Requests Limits %Limits Allocatable Schedulable Free
CPU 1834 91 1424 71 2002 168 168
Memory 3506438144 Err 3007315968 Err 0 0 0
System details
macOS 10.14.6
kubectl version
❯ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-14T04:24:34Z", GoVersion:"go1.12.13", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:09:08Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
kubectl view-utilization -v
❯ kubectl view-utilization -v
v0.3.1
Test is done on a namespace with the following used resources:
infra: hawkular-cassandra-1-rlcm8 / cpu: - / mem: 1G-2G
infra: hawkular-metrics-8cjz9 / cpu: - / mem: 1500M-2500M
infra: heapster-2s7jk / cpu: - / mem: 937500k-3750M
The template used for the pod computation gives the following intermediate result:
infra nod1.example.com 1G
infra inf.example.com 1500M
infra nod2.example.com 937500k
The final result is:
NAMESPACE CPU MEMORY
infra 939 0
The correct result should be:
NAMESPACE CPU MEMORY
infra 0 3.4G
Add the ability to sort results by column name
Hi, I am using ubuntu 16.04, with the below versions of the different components. The plugin does not work in this setup.
$ bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ awk -W version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan
compiled limits:
max NF 32767
sprintf buffer 2040
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.2", GitCommit:"cff46ab41ff0bb44d8584413b598ad8360ec1def", GitTreeState:"clean", BuildDate:"2019-01-10T23:35:51Z", GoVersion:"go1.11.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.8", GitCommit:"7eab6a49736cc7b01869a15f9f05dc5b49efb9fc", GitTreeState:"clean", BuildDate:"2018-09-14T15:54:20Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
$ kubectl krew install view-utilization
Updated the local copy of plugin index.
Installing plugin: view-utilization
W0128 15:49:33.278503 16523 install.go:128] Skipping plugin view-utilization, it is already installed
$ kubectl view-utilization
awk: line 13: syntax error at or near *
awk: line 14: syntax error at or near *
awk: line 15: syntax error at or near *
awk: line 16: syntax error at or near *
awk: line 16: extra ')'
kubectl
supports a --context
flag that is good for scripting where you don't want to change the current context in your kubeconfig. It would be nice for this script to support the same.
Thank you for the nice plugin. Can it be extended with information about other resources such as ephemeral storage?
Describe the bug
When current context is foo
and you pass --context foo
to this plugin it returns Context error
. Why would I do that you ask, well it is handy to loop over all contexts with kubectx
like this: for ctx in $(kubectx) ; do kubectl view-utilization --context $ctx -h ; done
.
System details
kubectl version
: 1.17.8kubectl view-utilization -v
: v0.3.2When displaying graph view of node utilization kubectl view-utilization nodes
memory graph is not showing bars with low utilization. Bars under 14% of utilization are not shown due to the bug in array index.
bar_index=int(int(int(a[n]-min)*2^8) / f )
awk arrays start with index 1 not 0
System details
To make installation easy for MacOS users we should support brew.
brew tap etopeter/kubectl-view-utilization
brew install kubectl-view-utilization
It would be nice to then be able to view the resources by pod in a given namespace. You can get that sort of view from:
kubectl describe nodes | grep
The format would be something like:
view-utilization -n -p
... where -p would be for "show pods"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.