A top-like tool for your Kubernetes clusters

ktop

ktop

A top-like tool for your Kubernetes cluster.

Following the tradition of Unix/Linux top tools, ktop is a tool that displays useful metrics information about nodes, pods, and other workload resources running in a Kubernetes cluster.

Features

  • Insightful summary of cluster resource metrics
  • Ability to work with or without a metrics-server deployed
  • Displays nodes and pods usage metrics when a Metrics Server is found
  • Uses your existing cluster configuration to connect to a cluster's API server

Installing ktop

kubectl ktop plugin

Project ktop is distributed as a kubectl plugin. To use ktop as a plugin do the followings:

  • Install krew plugin manager (if not present)
  • Ensure ktop is available to be installed: kubectl krew search ktop
  • Next, install the plugin: kubectl krew install ktop

Once installed, start the ktop plugin with

kubectl ktop

Download binary

Another easy way to get started with ktop is to download the pre-built binary (for your system):

https://github.com/vladimirvivien/ktop/releases/latest

Then, extract the ktop binary and copy it to your system's execution path.

Using go install

If you have a recent version of Go installed (1.14 or later) you can build and install ktop as follows:

go install github.com/vladimirvivien/ktop@latest

This should place the ktop binary in your configured $GOBIN path or place it in its default location, $HOME/go/bin.

Build from source

Download or clone the source (from GitHub). From the project's root directory, do the following:

go build .

The project also comes with a Go program that you can use for cross-platform builds.

go run ./ci/build.go

Running ktop

With a locally accessible kubeconfig file on your machine, ktop can be executed simply:

ktop

The previous command will use either environment variable $KUBECONFIG or the default path for the kubeconfig file. The program currently accepts the following arguments:

Usage:
  ktop [flags]

Flags:
  -A, --all-namespaces                 If true, display metrics for all accessible namespaces
      --as string                      Username to impersonate for the operation. User could be a regular user or a service account in a namespace.
      --as-group stringArray           Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
      --as-uid string                  UID to impersonate for the operation.
      --cache-dir string               Default cache directory (default "/Users/vivienv/.kube/cache")
      --certificate-authority string   Path to a cert file for the certificate authority
      --client-certificate string      Path to a client certificate file for TLS
      --client-key string              Path to a client key file for TLS
      --cluster string                 The name of the kubeconfig cluster to use
      --context string                 The name of the kubeconfig context to use
  -h, --help                           help for ktop
      --insecure-skip-tls-verify       If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
      --kubeconfig string              Path to the kubeconfig file to use for CLI requests.
  -n, --namespace string               If present, the namespace scope for this CLI request
      --request-timeout string         The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
  -s, --server string                  The address and port of the Kubernetes API server
      --tls-server-name string         Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used
      --token string                   Bearer token for authentication to the API server
      --user string                    The name of the kubeconfig user to use```

For instance, the following will show cluster information for workload resources associated with namespace my-app in context web-cluster using the default kubconfig file path:

ktop --namespace my-app --context web-cluster

ktop metrics

The ktop UI provides several metrics including a high-level summary of workload components installed on your cluster:

ktop

Usage metrics from metrics-server

ktop can display metrics with or without Metrics Server present. When a cluster has an instance of a kubernetes-sigs/metrics-server installed (and properly configured), ktop will automatically discover the server as shown:

ktop

With the metrics server installed, ktop will display resource utilization metrics as reported by the Metrics Server.

Request/limit metrics

When there is no Metrics Server present in the cluster, ktop will still work:

ktop

Instead of resource utilization, ktop will display resource requests and limits for nodes and pods.

Roadmap

  • A multi-page UI to display metrics for additional components
  • Display OOM processes
  • Additional installation methods (Homebrew, linux packages, etc)
  • Etc
Owner
Vladimir Vivien
Software Engineer, VMware
Vladimir Vivien
Comments
  • could not find the requested resource

    could not find the requested resource

    It's a bit hard to distinguish which resource ktop can't find that trying to access for.

    Version v0.2.0 (426916f7d1eb3d9da0586970b112f21d6ebdfff0)
    W0110 09:21:44.436882    4254 reflector.go:324] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: failed to list *unstructured.Unstructured: the server could not find the requested resource
    

    Maybe adding some verbosity here would be nice.

  • Error when building on Linux: 'utf-8' codec can't decode byte 0xc2 in position 6583: invalid continuation byte

    Error when building on Linux: 'utf-8' codec can't decode byte 0xc2 in position 6583: invalid continuation byte

    Hi,

    when building this package as an RPM on openSUSE, I get the following error:

    [  183s] ktop.x86_64: E: readelf-failed /usr/bin/ktop 'utf-8' codec can't decode byte 0xc2 in position 6583: invalid continuation byte
    [  183s] Executing readelf on this file failed, all checks could not be run.
    
    

    Any idea how to fix that? Is this something that needs to be done inside the source code or am I missing some flags for the build command? (Sorry, golang-Newbie here...)

  • How to see all info about  node/pod

    How to see all info about node/pod

    the ktop is good,thx to vladimirvivien

    but when I started the ktop, I can only see a part of nodes' info or pods' info,for example, the command only show 4 nodes info, althougth the cluster has 13 nodes, how can I see another 9 nodes' info?

    thank you!

  • Arrow keys in the UI

    Arrow keys in the UI

    Hi! I love your plugin, a lot of people in the office are now using it! I was wondering, it is possible to move in the UI? I got 6 nodes, but can only 4 of them, same for pods?

    image

  • Support kube-state-metrics in addition to metrics-server

    Support kube-state-metrics in addition to metrics-server

    First : great plugin, thanks !

    On a cluster with kube-prometheus stack deployed, the kube-state-metrics component replaces metrics-server to implement the K8S Metrics API. We deleted metrics-server from our clusters now that we know that it is redundant with kube-state-metrics and consequently, the ktop displays metrics: not connected

    It would be great if the plugin could detect kube-state-metrics when metrics-server is missing

  • Program shows long log output when server not available

    Program shows long log output when server not available

    When the API server is not available, ktop simply output a log message instead of immediately disconnecting

    kubectl ktop
    Connected to: http://localhost:8080
    ...
    W0108 13:32:42.673131   55437 reflector.go:324] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: failed to list *unstructured.Unstructured: Get "http://localhost:8080/apis/apps/v1/replicasets?limit=500&resourceVersion=0": dial tcp [::1]:8080: connect: connection refused
    W0108 13:32:42.673162   55437 reflector.go:324] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: failed to list *unstructured.Unstructured: Get "http://localhost:8080/apis/batch/v1/jobs?limit=500&resourceVersion=0": dial tcp [::1]:8080: connect: connection refused
    E0108 13:32:42.673484   55437 reflector.go:138] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: Get "http://localhost:8080/apis/apps/v1/replicasets?limit=500&resourceVersion=0": dial tcp [::1]:8080: connect: connection refused
    ...
    

    A better approach would be to stop sooner if the api server is not immediately available. Or, manage the UI better as a valid connection is being tried.

  • Overview screen not updating

    Overview screen not updating

    Panels on the overview screens not updating properly.

    1. Since resource pod (, node, etc) events are triggered by controllers, it seems the metrics dot update if ctrlr not firing
    2. When resources are removed, the panels are not updating their lists properly
  • Success report: Apple MacBook Air M1 + Rancher Desktop + ktop

    Success report: Apple MacBook Air M1 + Rancher Desktop + ktop

    OK to close this once reviewed - I want to report that Rancher Desktop ( https://github.com/rancher-sandbox/rancher-desktop ) works just fine with ktop running on a MacBook Air (M1). I installed the software with the supplied brew instructions, Thanks for a nifty tool and looking forward to how this develops.

  • Not able to start k8s client controller

    Not able to start k8s client controller

    Any pointers as to why this could happen? I tried connecting to two different clusters: v1.20.2 (kind cluster), v1.18.20-gke.3000

    >> kubectl-ktop --context REDACTED --namespace REDACTED
     _    _
    | | _| |_ ___  _ __
    | |/ / __/ _ \| '_ \
    |   <| || (_) | |_) |
    |_|\_\\__\___/| .__/
                  |_|
    Version v0.2.0 (426916f7d1eb3d9da0586970b112f21d6ebdfff0)
    W0113 18:54:57.725344   94762 reflector.go:324] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: failed to list *unstructured.Unstructured: the server could not find the requested resource
    E0113 18:54:57.725619   94762 reflector.go:138] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: the server could not find the requested resource
    W0113 18:54:58.869531   94762 reflector.go:324] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: failed to list *unstructured.Unstructured: the server could not find the requested resource
    E0113 18:54:58.869558   94762 reflector.go:138] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: the server could not find the requested resource
    W0113 18:55:01.774346   94762 reflector.go:324] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: failed to list *unstructured.Unstructured: the server could not find the requested resource
    E0113 18:55:01.774377   94762 reflector.go:138] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:167: Failed to watch *unstructured.Unstructured: failed to list *unstructured.Unstructured: the server could not find the requested resource
    
  • Graceful authorization handling

    Graceful authorization handling

    This patch handles authorization issues which are discussed in #5, #9, and #11.

    The code does an early assessment of authorization and stops the program if authorization to core resources are not granted for the user.

  • Support for kubectl/krew plugin

    Support for kubectl/krew plugin

    Support for ktop to run as a kubectl plugin and be managed in krew. Once complete, users will be able to launch the program in either of the following ways:

    ktop 
    

    Or,

    kubectl ktop
    
  • Add additional metrics screens

    Add additional metrics screens

    Currently, ktop can only show runtime metrics collected by metrics-server when installed on the cluster. Kubernetes, however, capture far more metrics, by default, that are not piped into the metrics-server. As a user, it would be useful to get access to these additional metrics such as those collected in kube-steate-metrics.

  • Add documentation for functionalities

    Add documentation for functionalities

    The project lacks documentation. As a user I would like to read how to effectively use the tool. This should include

    • GitHub project documentation
    • Or, a separate doc website (optional)
  • Pods panel is empty: couldn't fetch from API

    Pods panel is empty: couldn't fetch from API

    I just tried the latest (v0.3.0) version and noticed ktop couldn't fill the pods.

    Screen Shot 2022-06-14 at 17 09 08

    But there are 570 pods:

    $ kubectl get pods -A | wc -l
    
    570
    

    Any thoughts on this?

Related tags
vcluster - Create fully functional virtual Kubernetes clusters - Each cluster runs inside a Kubernetes namespace and can be started within seconds
vcluster - Create fully functional virtual Kubernetes clusters - Each cluster runs inside a Kubernetes namespace and can be started within seconds

Website • Quickstart • Documentation • Blog • Twitter • Slack vcluster - Virtual Clusters For Kubernetes Lightweight & Low-Overhead - Based on k3s, bu

Jan 4, 2023
Kubernetes IN Docker - local clusters for testing Kubernetes
Kubernetes IN Docker - local clusters for testing Kubernetes

kind is a tool for running local Kubernetes clusters using Docker container "nodes".

Jan 5, 2023
provider-kubernetes is a Crossplane Provider that enables deployment and management of arbitrary Kubernetes objects on clusters

provider-kubernetes provider-kubernetes is a Crossplane Provider that enables deployment and management of arbitrary Kubernetes objects on clusters ty

Dec 14, 2022
Crossplane provider to provision and manage Kubernetes objects on (remote) Kubernetes clusters.

provider-kubernetes provider-kubernetes is a Crossplane Provider that enables deployment and management of arbitrary Kubernetes objects on clusters ty

Jan 3, 2023
Kubernetes IN Docker - local clusters for testing Kubernetes
Kubernetes IN Docker - local clusters for testing Kubernetes

Please see Our Documentation for more in-depth installation etc. kind is a tool for running local Kubernetes clusters using Docker container "nodes".

Feb 14, 2022
Kubernetes OS Server - Kubernetes Extension API server exposing OS configuration like sysctl via Kubernetes API

KOSS is a Extension API Server which exposes OS properties and functionality using Kubernetes API, so it can be accessed using e.g. kubectl. At the moment this is highly experimental and only managing sysctl is supported. To make things actually usable, you must run KOSS binary as root on the machine you will be managing.

May 19, 2021
🐶 Kubernetes CLI To Manage Your Clusters In Style!
🐶 Kubernetes CLI To Manage Your Clusters In Style!

K9s - Kubernetes CLI To Manage Your Clusters In Style! K9s provides a terminal UI to interact with your Kubernetes clusters. The aim of this project i

Jan 9, 2023
Validation of best practices in your Kubernetes clusters
Validation of best practices in your Kubernetes clusters

Best Practices for Kubernetes Workload Configuration Fairwinds' Polaris keeps your clusters sailing smoothly. It runs a variety of checks to ensure th

Jan 9, 2023
Client extension for interacting with Kubernetes clusters from your k6 tests.

⚠️ This is a proof of concept As this is a proof of concept, it won't be supported by the k6 team. It may also break in the future as xk6 evolves. USE

Jan 2, 2023
Managing your Kubernetes clusters (including public, private, edge, etc) as easily as visiting the Internet

Clusternet Managing Your Clusters (including public, private, hybrid, edge, etc) as easily as Visiting the Internet. Clusternet (Cluster Internet) is

Dec 30, 2022
A pain of glass between you and your Kubernetes clusters.

kube-lock A pain of glass between you and your Kubernetes clusters. Sits as a middle-man between you and kubectl, allowing you to lock and unlock cont

Oct 20, 2022
Hot-swap Kubernetes clusters while keeping your microservices up and running.

Okra Okra is a Kubernetes controller and a set of CRDs which provide advanced multi-cluster appilcation rollout capabilities, such as canary deploymen

Nov 23, 2022
Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration, and automating updates to configuration when there is new code to deploy.
Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration, and automating updates to configuration when there is new code to deploy.

Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration (like Git repositories), and automating updates to configuration when there is new code to deploy.

Jan 8, 2023
Flux prometheus grafana-example - A tool for keeping Kubernetes clusters in sync with sources ofconfiguration
Flux prometheus grafana-example - A tool for keeping Kubernetes clusters in sync with sources ofconfiguration

Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration (like Git repositories), and automating updates to configuration when there is new code to deploy.

Feb 1, 2022
kubequery is a Osquery extension that provides SQL based analytics for Kubernetes clusters

kubequery powered by Osquery kubequery is a Osquery extension that provides SQL based analytics for Kubernetes clusters kubequery will be packaged as

Dec 27, 2022
Manage large fleets of Kubernetes clusters
Manage large fleets of Kubernetes clusters

Introduction Fleet is GitOps at scale. Fleet is designed to manage up to a million clusters. It's also lightweight enough that it works great for a si

Dec 31, 2022
A best practices checker for Kubernetes clusters. 🤠

Clusterlint As clusters scale and become increasingly difficult to maintain, clusterlint helps operators conform to Kubernetes best practices around r

Dec 29, 2022
Kubernetes operator to autoscale Google's Cloud Bigtable clusters
Kubernetes operator to autoscale Google's Cloud Bigtable clusters

Bigtable Autoscaler Operator Bigtable Autoscaler Operator is a Kubernetes Operator to autoscale the number of nodes of a Google Cloud Bigtable instanc

Nov 5, 2021
Nebula Operator manages NebulaGraph clusters on Kubernetes and automates tasks related to operating a NebulaGraph cluster

Nebula Operator manages NebulaGraph clusters on Kubernetes and automates tasks related to operating a NebulaGraph cluster. It evolved from NebulaGraph Cloud Service, makes NebulaGraph a truly cloud-native database.

Dec 31, 2022