Giter VIP home page Giter VIP logo

kom's Introduction

"Buy Me A Coffee"

KOM - Kubernetes Object Metrics CLI tool

Kom is a command-line tool written in Go that allows you to display Kubernetes metrics for nodes and pods. It provides an easy way to monitor resource usage and quickly identify performance issues in your Kubernetes cluster.

Features

  • View CPU and memory usage metrics for all nodes in the cluster.
  • View CPU and memory usage metrics for all pods in the cluster.
  • View Logs from pods and save inside folder komlogs
  • Color-coded output for easy visualization of resource usage levels.

Color-Coded Output

Kom uses color-coding to visualize resource usage levels:

  • CPU usage above 80% is displayed in red.
  • CPU usage between 50% and 80% is displayed in yellow.
  • CPU usage below 50% is displayed in green.
  • Memory usage above 80% is displayed in red.
  • Memory usage between 50% and 80% is displayed in yellow.
  • Memory usage below 50% is displayed in green.

Installation

Assuming you have Git and Go installed on your system, here's what you can do:

Clone the repository:

git clone https://github.com/miltlima/kom.git

Change to the project directory:

cd kom

Build the binary:

go build

This will generate a binary file named "kom" in the project directory.

sudo mv kom /usr/local/bin

Now, the "kom" binary is located in your bin folder, and you can run it from any terminal window as long as the bin folder is in your system's PATH.

Save the file and either restart your terminal or run source to apply the changes:

source ~/.bashrc

Or

source ~/.bash_profile

Now, you should be able to run the "kom" command from anywhere in your terminal.

Usage

Kom nodes

To display metrics for all nodes in the Kubernetes cluster, use the following command:

kom nodes

This will show a table with information about each node's CPU usage, memory usage, and IP addresses.

โฏ ./kom nodes

+-------+-----------+-------------+----------------+----+-----------------------------------------------------------+
| NODE  |    IP     | CPU USAGE % | MEMORY USAGE % | H  |                      STATUS - LABELS                      |
+-------+-----------+-------------+----------------+----+-----------------------------------------------------------+
| node1 | 10.0.0.11 | 7           | 42             | ๐ŸŸฉ | OK, Has Labels: node-role.kubernetes.io/control-plane=,   |
|       |           |             |                |    | node.kubernetes.io/exclude-from-external-load-balancers=, |
|       |           |             |                |    | beta.kubernetes.io/arch=arm64,                            |
|       |           |             |                |    | beta.kubernetes.io/os=linux, kubernetes.io/arch=arm64,    |
|       |           |             |                |    | kubernetes.io/hostname=node1, kubernetes.io/os=linux      |
| node2 | 10.0.0.12 | 2           | 44             | ๐ŸŸฉ | OK, Has Labels:                                           |
|       |           |             |                |    | kubernetes.io/arch=arm64,                                 |
|       |           |             |                |    | kubernetes.io/hostname=node2,                             |
|       |           |             |                |    | kubernetes.io/os=linux,                                   |
|       |           |             |                |    | beta.kubernetes.io/arch=arm64,                            |
|       |           |             |                |    | beta.kubernetes.io/os=linux                               |
| node3 | 10.0.0.13 | 2           | 37             | ๐ŸŸฉ | OK, Has Labels:                                           |
|       |           |             |                |    | kubernetes.io/os=linux,                                   |
|       |           |             |                |    | beta.kubernetes.io/arch=arm64,                            |
|       |           |             |                |    | beta.kubernetes.io/os=linux,                              |
|       |           |             |                |    | kubernetes.io/arch=arm64,                                 |
|       |           |             |                |    | kubernetes.io/hostname=node3                              |
| node4 | 10.0.0.14 | 4           | 36             | ๐ŸŸฉ | OK, Has Labels:                                           |
|       |           |             |                |    | kubernetes.io/hostname=node4,                             |
|       |           |             |                |    | kubernetes.io/os=linux,                                   |
|       |           |             |                |    | beta.kubernetes.io/arch=arm64,                            |
|       |           |             |                |    | beta.kubernetes.io/os=linux,                              |
|       |           |             |                |    | kubernetes.io/arch=arm64                                  |
+-------+-----------+-------------+----------------+----+-----------------------------------------------------------+

Kom pods

To display metrics for all pods in the Kubernetes cluster, use the following command:

kom pods

This will show a table with information about each node, pod's namespace, name, CPU usage, memory usage, and IP.

โฏ ./kom pods
+-------+-------------+--------------------------------------------------+-----------+-------------+----------------+----+
| NODE  |  NAMESPACE  |                       POD                        |  POD IP   | CPU USAGE % | MEMORY USAGE % | H  |
+-------+-------------+--------------------------------------------------+-----------+-------------+----------------+----+
| node2 | default     | build-code-deployment-68dd47875-4bt5p            | 10.36.0.1 | 0           | 0              | ๐ŸŸฉ |
| node2 | default     | health-check-deployment-59f4b679b-8k4pj          | 10.36.0.5 | 0           | 0              | ๐ŸŸฉ |
| node3 | default     | hidden-in-layers-qtst5                           | 10.44.0.1 | 0           | 0              | ๐ŸŸฉ |
| node2 | default     | internal-proxy-deployment-7699c5dd65-xm4tw       | 10.36.0.3 | 0           | 0              | ๐ŸŸฉ |
| node2 | default     | kubernetes-goat-home-deployment-7bf7785ff5-gghts | 10.36.0.2 | 0           | 0              | ๐ŸŸฉ |
| node4 | default     | metadata-db-648b64948f-vjvsg                     | 10.42.0.1 | 0           | 0              | ๐ŸŸฉ |
| node2 | default     | poor-registry-deployment-75f47d55dc-vhs9d        | 10.36.0.4 | 0           | 0              | ๐ŸŸฉ |
| node4 | default     | system-monitor-deployment-674bb4dc65-9wj4m       | 10.42.0.3 | 0           | 0              | ๐ŸŸฉ |
| node1 | kube-system | coredns-787d4945fb-4vnqj                         | 10.32.0.3 | 0           | 0              | ๐ŸŸฉ |
| node1 | kube-system | coredns-787d4945fb-q5r2h                         | 10.32.0.2 | 0           | 0              | ๐ŸŸฉ |
| node1 | kube-system | etcd-node1                                       | 10.0.0.11 | 1           | 1              | ๐ŸŸฉ |
| node1 | kube-system | kube-apiserver-node1                             | 10.0.0.11 | 3           | 8              | ๐ŸŸฉ |
| node1 | kube-system | kube-controller-manager-node1                    | 10.0.0.11 | 0           | 0              | ๐ŸŸฉ |
| node4 | kube-system | kube-proxy-5r278                                 | 10.0.0.14 | 0           | 0              | ๐ŸŸฉ |
| node3 | kube-system | kube-proxy-dzzrp                                 | 10.0.0.13 | 0           | 0              | ๐ŸŸฉ |
| node1 | kube-system | kube-proxy-h5wsb                                 | 10.0.0.11 | 0           | 0              | ๐ŸŸฉ |
| node2 | kube-system | kube-proxy-htlwv                                 | 10.0.0.12 | 0           | 0              | ๐ŸŸฉ |
| node1 | kube-system | kube-scheduler-node1                             | 10.0.0.11 | 0           | 0              | ๐ŸŸฉ |
| node4 | kube-system | metrics-server-75fcb88b7d-n2l7p                  | 10.0.0.14 | 0           | 0              | ๐ŸŸฉ |
| node4 | kube-system | weave-net-774l4                                  | 10.0.0.14 | 0           | 0              | ๐ŸŸฉ |
| node3 | kube-system | weave-net-gv6dn                                  | 10.0.0.13 | 0           | 0              | ๐ŸŸฉ |
| node2 | kube-system | weave-net-n6n8f                                  | 10.0.0.12 | 0           | 0              | ๐ŸŸฉ |
| node1 | kube-system | weave-net-sn6v9                                  | 10.0.0.11 | 0           | 0              | ๐ŸŸฉ |
+-------+-------------+--------------------------------------------------+-----------+-------------+----------------+----+

Kom logs

The logs command in the kom CLI allows you to collect logs from a Kubernetes pod and optionally save them to a file.

kom logs <pod-name> [flags]

Arguments

<pod-name>: The name of the pod from which you want to collect logs.

Flags

-s, --save: (Optional) Save the output to a log file. If this flag is not provided, the logs will be displayed in the terminal.
-o, --output <file-path>: (Optional) Specify the file path to save the logs. Default is output.log in the komlogs folder.
-n, --namespace <namespace>: (Optional) Specify the namespace of the pod. Default is default.
-c, --container <container-name>: (Optional) Specify the name of the container in the pod. If not provided, logs will be collected from the first container in the pod.

kom's People

Contributors

miltlima avatar

Stargazers

 avatar Franciosi avatar Adรฃo Santos avatar Leonardo Biffi avatar Isaac Mecchi avatar Elton Ribeiro avatar

Watchers

 avatar

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.