Skip to content

fioletoven/b4n

Repository files navigation

b4n

b4n is a terminal user interface (TUI) for the Kubernetes API, created mainly for learning the Rust programming language. It is heavily based on the k9s project and built using the kube-rs and ratatui crates.

b4n demo

Prerequisites

The Cascadia Code font, or any other font with Nerd Font symbols, is required for proper display of the user interface in the terminal.

Features

Currently Supported

The following features are currently supported:

  • View a list of Kubernetes resources.
  • Create Kubernetes resources.
  • Delete selected resources.
  • Display and edit YAML of the highlighted resource.
  • View events for the highlighted resource.
  • View logs for the highlighted container.
  • Open a shell session in the highlighted container.
  • Enable port forwarding for the highlighted container.

Planned

The following features are planned for future development:

  • View combined logs for all containers in a pod.
  • Describe Kubernetes resources.

Default Key Bindings

Action Command Comments
Attach to the container's shell s Works only in containers view
Copy YAML / logs to the clipboard c Works only in YAML and logs views
Create new resource n
Decode highlighted secret x
Delete selected resources CTRL + d Displays a confirmation dialog
Enable / disable mouse support CTRL + n Not available inside a shell session
Forward container's port f Works only in containers view
Go back to namespaces; clear filter ESC Also clears input in the filter widget
Navigate to the involved object i Works only for a resource that has an involved object
Quit the application CTRL + c
Reverse selection CTRL +   (CTRL + SPACE)
Select resource   (SPACE)
Show / hide log timestamps t Works only in logs view
Show / hide port forwards CTRL + f Displays all active port forwarding rules
Show command palette :, > For example, entering :q↲ quits the application
Show events for the highlighted resource e
Show filter / search input / Filter operators: and &, or |, negation !, (, )
Show logs for the highlighted container l Press p to display previous logs for the container
Show namespaces selector To select all quickly press again
Show resources selector To select the first item quickly press again
Show YAML for the highlighted resource y
Sort column ALT + [0-9] Also works ALT + [underlined letter]
Switch to the edit mode i Works only in YAML view, press Esc to exit

Configuration Files

Configuration files are stored in the $HOME/.b4n directory. The directory structure is as follows:

.b4n/
├─ logs/
├─ themes/
│  └─ default.yaml
├─ config.yaml
└─ history.yaml

logs/

This directory contains application logs, with one log file generated per day.

themes/

This folder stores all TUI (Text User Interface) themes.
The default.yaml theme will be automatically generated by the application if it doesn't already exist.

You can place additional theme files here by copying them from the themes folder or creating your own.

config.yaml

This file contains configuration settings that control the behaviour of the b4n application.
Here is an example structure:

logs:
  lines: 800
mouse: true
theme: light
contexts:
  test-cluster: '#43464f:#8aad81'
  production: '#d8d8d8:#e1140a'
key_bindings:
  action.name: list of key bindings for that action
  command-palette.open: :, >, Shift+:, Shift+>
  [...]

Configuration Options

  • logs.lines – The number of log lines to retrieve from the Kubernetes API for selected container.
  • mouse – Indicates if mouse support should be enabled when the application starts. Mouse support can also be toggled while the app is running.
  • theme – The name of the currently selected theme. This should match a file in the themes directory (without the .yaml extension).
  • contexts - (Optional) A map of context names to their corresponding colors. Useful for highlighting important Kubernetes clusters with distinct header colors.
  • key_bindings – Defines custom key bindings for various application actions.
    Example key bindings: Ctrl+C, Ctrl+Alt+A, F7, Z, Left, Enter.

If config.yaml does not exist, the application will create it automatically with default values.

history.yaml

This file stores history for filters, search patterns, and the last selected resource for each Kubernetes context. To remove history entries (either for a specific context or entirely), you can manually edit this file or even delete it.

License

MIT