In this blog, you will learn about a monitoring tool called ktop.
Kubernetes does not natively provide real-time resource usage monitoring and visualization, which can make it challenging to track the current performance of nodes, pods, and other resources.
This is where ktop comes in, a tool designed to display real-time metrics of Kubernetes nodes and pods within a cluster and is similar to the classic top command.
It offers a way to monitor resource usage, making it easier to manage and optimize your clusterβs performance, which can help troubleshoot performance bottlenecks, diagnose issues, and optimize resource usage.
Install ktop
Before installing ktop, make sure you have installed a metrics server in your system because it gets the metrics from the Metrics server.
If you don't have a metrics server in your system, run the following command to install it
Copy the ktop binary to your system's execution path
sudo mv ktop /usr/local/bin/
For other installation methods, refer to the official GitHub repo.
Get Metrics using ktop
Run the following command to get the metrics of all resources in your cluster.
ktop
You will get the metrics of every node, pod, and other details of your cluster.
In the top block, you will get the URL of your API server, cluster version, name of the current cluter you are using, user name, namespace and if ktop is connected to metrics server or not.
And, in the second block you will get the objects details like, number of namespaces, pods, PVs, etc,..
In the third block, you will get the list of every node available and their details (Version, Disk size, memory and CPU usage, etc).
The last block shows the list of every pod running on your cluster.
If you want the metrics of Pod in a specific namespace, run the following command.
ktop -n default
Ktop uses the current cluster you are configured to your system, let's say you have multiple clusters running, and you want to get the metrics of a specific cluster.
First get the context name of the cluster configured in theKubeconfig file, and run the following command to get every available context in your system.
kubectl config get-contexts
Then, use the context name of the cluster you want to get the metrics in below command
ktop --context kubernetes-admin@kubernetes
Replace kubernetes-admin@kubernetes with your cluster's context name.
If you want to get the metrics of a specific namespace, run the following command
Aswin Vijayan is a DevOps engineer with a passion for open-source tools and automation. In his free time, Aswin enjoys reading and exploring new technologies.
KTOP: Real-time Kubernetes Resource Usage Monitoring
β Aswin
KTOP: Real-time Kubernetes Resource Usage Monitoring
In this blog, you will learn about a monitoring tool called ktop.
Kubernetes does not natively provide real-time resource usage monitoring and visualization, which can make it challenging to track the current performance of nodes, pods, and other resources.
This is where
ktop
comes in, a tool designed to display real-time metrics of Kubernetes nodes and pods within a cluster and is similar to the classictop
command.It offers a way to monitor resource usage, making it easier to manage and optimize your clusterβs performance, which can help troubleshoot performance bottlenecks, diagnose issues, and optimize resource usage.
Install ktop
Before installing ktop, make sure you have installed a metrics server in your system because it gets the metrics from the Metrics server.
If you don't have a metrics server in your system, run the following command to install it
Now, visit the official ktop releases page and download the latest binary for your system.
Download the tar file using the curl command as given below
Extract the downloaded binary
Copy the ktop binary to your system's execution path
For other installation methods, refer to the official GitHub repo.
Get Metrics using ktop
Run the following command to get the metrics of all resources in your cluster.
You will get the metrics of every node, pod, and other details of your cluster.
In the top block, you will get the URL of your API server, cluster version, name of the current cluter you are using, user name, namespace and if ktop is connected to metrics server or not.
And, in the second block you will get the objects details like, number of namespaces, pods, PVs, etc,..
In the third block, you will get the list of every node available and their details (Version, Disk size, memory and CPU usage, etc).
The last block shows the list of every pod running on your cluster.
If you want the metrics of Pod in a specific namespace, run the following command.
Ktop uses the current cluster you are configured to your system, let's say you have multiple clusters running, and you want to get the metrics of a specific cluster.
First get the context name of the cluster configured in the
Kubeconfig file
, and run the following command to get every available context in your system.Then, use the context name of the cluster you want to get the metrics in below command
Replace
kubernetes-admin@kubernetes
with your cluster's context name.If you want to get the metrics of a specific namespace, run the following command
Aswin Vijayan is a DevOps engineer with a passion for open-source tools and automation. In his free time, Aswin enjoys reading and exploring new technologies.