Giter VIP home page Giter VIP logo

kubectl-view-utilization's People

Contributors

2rs2ts avatar achals avatar etopeter avatar hayorov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kubectl-view-utilization's Issues

Node utilization visualization

Graphical representation of utilization. We could use ASCII characters to represent node. Optional colors could be also used to represent intensity.

Feature request: filter output by node role or other labels

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?

memory graph not showing low utilization

When 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

  • Operating system that client is running: MacOS
  • kubectl client and server version: v1.15.3, v1.13.10-eks-5ac0f1
  • view-utilization plugin version: v0.3.0

Feature request: json output

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
  }
}

Node cpu Request not reporting correct

Describe the bug
kubectl view-utilization nodes command not returning correct values for CPU Request for nodes
System details

  • Operating system that client is running Big Sur 11.4
  • kubectl client and server version 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
  • view-utilization plugin version 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

Problems with memory output

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

  • Operating system that client is running: Debian Buster
  • kubectl client and server version kubectl version: 1.17.8
  • view-utilization plugin version kubectl view-utilization -v: v0.3.2

`kubectl view-utilization` broken

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

  • Operating system that client is running
    MacOS 10.15.3, CentOS7/8, Docker 2.2.0.4
  • kubectl client and server version kubectl version
    1.16.6
  • view-utilization plugin version kubectl view-utilization -v
    kubectl view-utilization -v is precisely what doesn't work :) but its v0.3.2

Feature request: support --context flag

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.

Utilization % doesn't change when nodes are drained

Steps to reproduce:

  1. watch kubectl-view-utilization
  2. kubectl drain some nodes
  3. you will see that %s don't change, neither does schedulable

I think this might be a flaw in kubernetes itself but maybe there is a workaround?

human readable format doesn't work for CPU.allocatable

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

  • Operating system that client is running
  • kubectl client and server version kubectl version
v0.3.3
  • view-utilization plugin version 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"}

[krew] Distribute with license

👋 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?

  • Please ensure your GitHub repository has a license file.
  • Make sure your archive file (.tar.gz or .zip) contains the license file.
  • Please submit a pull-request to krew-index and update the 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/files

If you need further assistance, don't hesitate to ask for help.

Memory report showing error

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

  • Operating system that client is running: macOS 10.14.6
  • kubectl client and server version 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"}
  • view-utilization plugin version kubectl view-utilization -v
❯ kubectl view-utilization -v
v0.3.1

Bad resource computation for pods.

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

"Context error" when passing --context that is the current context

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

  • Operating system that client is running: Debian buster:
  • kubectl client and server version kubectl version: 1.17.8
  • view-utilization plugin version kubectl view-utilization -v: v0.3.2

Plugin does not work

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 ')'

Installation with brew

To make installation easy for MacOS users we should support brew.

brew tap etopeter/kubectl-view-utilization
brew install kubectl-view-utilization

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.