An open API service indexing awesome lists of open source software.

https://github.com/night-crawler/kgv

Curses-based terminal UI for Kubernetes (k8s Global View)
https://github.com/night-crawler/kgv

cursive-rs kubernetes rust terminal tui

Last synced: about 1 year ago
JSON representation

Curses-based terminal UI for Kubernetes (k8s Global View)

Awesome Lists containing this project

README

          

# KGV

[![Rust](https://github.com/night-crawler/kgv/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/night-crawler/kgv/actions/workflows/rust.yml)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)

`KGV` is Kubernetes Global View or an acronym for GVK. It's a Terminal UI for observing and manipulating Kubernetes
resources.

## Features

1. [rhai](https://rhai.rs/)-based data extraction for table views. Write a small script to extract the data for each
column for a given GVK. Data extraction is parallel.
2. Rhai module support. Use imports and reuse the code.
3. Detail view templates are defined as Handlebars HTML templates, rendered against the resource context, and then
converted to ASCII using [cursive-markup](https://docs.rs/cursive-markup/latest/cursive_markup/).
4. Live reloading support for the rhai engine and templates.
5. Live updates for the detail, YAML, and list views.
6. Collecting initial GVK resource names is cached. Startup on overprovisioned or overloaded k8s installations is
faster.
7. Multiple window support. Open multiple windows (logs, list views, list details views, or just details views) and
switch between them. Switching is instant.
8. Custom user dirs support. Specify your modules and templates dirs with CMD arguments.

## Screenshots


Table View: Pods
Table View: Pod Containers
Handlebars HTML Detail View
YAML View
Window Switcher View
GVK Switcher View
Logs View
Menu
Port Forwarding Dialog
Port Forwarding View

### Minor features

- Rhai debugs are transferred to the main debug window
- Handlebars template includes and inheritance support
- YAML partial code extractors for Handlebars (use `to_yaml` helper)

## Hotkeys

- `~`: Show Debug Console
- `Esc`: Close the current window
- `Ctrl+s`: execute `kubectl exec -it`
- `Alt+=`: Show windows view
- `Ctrl+p`: Dump rhai object to temp
- `F5`: Refresh the view (clears deleted items)
- `Ctrl+y`: Show Resource YAML view
- `Ctrl+/`: Show a list of registered GVKs
- `Ctrl+k`: Delete current selected resource
- `Ctrl+l`: Show logs for the selected resource
- `Ctrl+f`: Show Port Forwarding dialog for the selected pod
- `Ctrl+g`: Show active Port Forwards

## Run

```shell
RUST_BACKTRACE=1 cargo run -- --module-dirs ./default_config/modules --extractor-dirs ./default_config/views/list --detail-template-dirs ./default_config/views/detail
```

## Adding new Resource / GVK support

1. Describe the Resource List view YAML. Top-level sections are:
- `resource`: there you describe Group, Version, Kind
- `imports`: automatically prepend for each column evaluator script these lines
- `pseudo_resources`: an extractor for nested resource list (return a list of `PseudoResource` items; for `Pod`
pseudo-resource is a container)
- `events`: show either a pseudo resource table or an HTML detail template
- `columns`: a list of column evaluators with column names
- `details`: for HTML-based views specify a root template and rhai helpers
2. If you need an HTML detail view, describe templates. Includes and template inheritance is supported.
3. When writing column evaluators, use `Ctrl+P` hotkey to extract currently selected resource as a rhai object.

## TODO

- [ ] Resource multiselect (i.e., to delete multiple resources at once)
- [ ] Resource kill options support
- [x] Faster Log view
- [ ] Better shell selector (now it uses `sh` always)
- [x] Port Forwarding
- [ ] Configurable hotkeys
- [ ] rhai-based context extractors for rendering with support for multiple resources (when you need to solve N+1
problem for resource detail view and show some dependencies)
- [ ] Log mirroring to a file
- [ ] Prepare more detail and list views for more GVKs
- [x] Support for popular CRDs (helm, GitOps, etc)
- [ ] Solve a problem with panics handler breaking the terminal