Kubernetes Node Usage or Kube-Node-Usage is a CLI tool to get the Memory, CPU and Disk Usage of Kubernetes Nodes
it is designed on python and relies on the kubectl
installed in your local.
No Authentication data are directly handled.
You can think of Kube-Node-Usage
as a wrapper over kubectl get nodes
command
Kube-Node-Usage simply execute the kubectl get nodes
command and parse the output and present it to you with a nice formatting and Usage Bar
Kubectl
must be installed and configuredPython3
must be installed and used to run the kube-node-usagepip
package manager is required to install the necassary python packages- Must have required Kubernetes Cluster accessr. As we have mentioned. kube-node-usage simply run the
kubectl get nodes
command and parse the output and present it to you.
-
In earlier release
v1.0.1
we supported the short hand arguments like-d
,-m
,-c
to represent the disk, memory and cpu respectively. It is now removed for much cleaner approach. Only full forms are supported--cpu, --memory, --disk
-
Release
v1.0.2
is powered with unix stylegetopts
comparing to the if - else style on thev1.0.1
-
Two startup arguments/options are added with this release
--sort=
to sort by the output fields in ascending order by default--reverse
to enable reverse sorting, in descending order
- Clone the repository
git clone https://github.com/AKSarav/Kube-Node-Usage.git
- Install the necassary packages with the following PIP command.
We presume you have pip and python3 installed
pip install -r requirements.txt
- Execute the command to list the kubernetes nodes with their Usage Information
For some reason, If you do not wish to install the required python packages into the entire system
You can create your virtual environment (virtualenv) and install the packages
Here are the commands for the same
# python -m venv venv
# source venv/bin/activate
# pip install -r requirements.txt
Once you have used the kube-node-usage
you can execute the deactivate
command
# deactivate
Here are the list of commands Kube-Node-Usage supports and how it can be used.
Note: By default the results are sorted in ascending order by the Node Name. You can control the sort behaviour with
--sort
and--reverse
args
##### List the Node with Disk Usage
To list the Kubernetes nodes with Disk Usage execute the following command
# python kube-node-usage.py --disk
To List the Nodes with CPU Usage with sort
You can sort the output based on each displayed field
- Node Name
- Free
- Max
- Usage
# python kube-node-usage.py --disk --sort=max
# python kube-node-usage.py --disk --sort=free
# python kube-node-usage.py --disk --sort=node
# python kube-node-usage.py --disk --sort=usage
To list the Kubernetes nodes with CPU Usage execute the following command
# python kube-node-usage.py --cpu
To List the Nodes with CPU Usage with sort
You can sort the output based on each displayed field
- Node Name
- Free
- Max
- Usage
# python kube-node-usage.py --cpu --sort=max
# python kube-node-usage.py --cpu --sort=free
# python kube-node-usage.py --cpu --sort=node
# python kube-node-usage.py --cpu --sort=usage
To list the Kubernetes nodes with Memory Usage execute the following command
# python kube-node-usage.py --memory
To List the Nodes with Memory Usage with sort
You can sort the output based on each displayed field
- Node Name
- Free
- Max
- Usage
# python kube-node-usage.py --memory --sort=max
# python kube-node-usage.py --memory --sort=free
# python kube-node-usage.py --memory --sort=node
# python kube-node-usage.py --memory --sort=usage
To list the Kubernetes nodes with All ( CPU, Memory, Disk) Usage execute the following command
# python kube-node-usage.py --all
To List the Nodes with All ( CPU, Memory, Disk) Usage with sort
You can sort the output based on each displayed field
- Node Name
- Free
- Max
- Usage
# python kube-node-usage.py --all --sort=max
# python kube-node-usage.py --all --sort=free
# python kube-node-usage.py --all --sort=node
# python kube-node-usage.py --all --sort=usage
By Default, sort
option do the sort in ASCENDING
order
If you want to do the sort
in DESCENDING
order
All Option Commands with Sort and Reverse
# python kube-node-usage.py --all --sort=max --reverse
# python kube-node-usage.py --all --sort=free --reverse
# python kube-node-usage.py --all --sort=node --reverse
# python kube-node-usage.py --all --sort=usage --reverse
Disk related Commands with Memory and Reverse
# python kube-node-usage.py --memory --sort=max --reverse
# python kube-node-usage.py --memory --sort=free --reverse
# python kube-node-usage.py --memory --sort=node --reverse
# python kube-node-usage.py --memory --sort=usage --reverse
CPU related Commands with Sort and Reverse
# python kube-node-usage.py --cpu --sort=max --reverse
# python kube-node-usage.py --cpu --sort=free --reverse
# python kube-node-usage.py --cpu --sort=node --reverse
# python kube-node-usage.py --cpu --sort=usage --reverse
Disk related Commands with Sort and Reverse
# python kube-node-usage.py --disk --sort=max --reverse
# python kube-node-usage.py --disk --sort=free --reverse
# python kube-node-usage.py --disk --sort=node --reverse
# python kube-node-usage.py --disk --sort=usage --reverse
Note
All the data shown here are created with Random Usage data. The Free, Max and the Usage% may not add up
**Kubernetes Nodes CPU Usage - Release 1.0.2** This is a screenshot taken from Release 1.0.2
Kubernetes Nodes Memory Usage - Release 1.0.2 This is a screenshot taken from Release 1.0.2
Kubernetes Nodes Disk Usage - Release 1.0.2 This is a screenshot taken from Release 1.0.2
Feel free to send your Pull requests to make this tool better.
If you happen to see any issues. please create an issue and I will have it checked.
### If you like this tool. please let me know by clicking on the Github Stars
Linked in : https://www.linkedin.com/in/saravakdevopsjunction/ Website: https://devopsjunction.com