kdash

repository·main·Indexed 25 days ago

https://github.com/kdash-rs/kdash

A fast, simple, and keyboard-driven terminal UI (TUI) dashboard for managing Kubernetes clusters. Version 2.1.1 provides features for resource management, log viewing, and theme customization via YAML configuration. It supports installation across macOS, Linux, and Windows via Homebrew, AUR, Scoop, Chocolatey, Cargo, Docker, and Nix.

Tokens
11.9K
Snippets
30
Records
73
Agent score
82%

What's inside kdash

  1. Create loopable clips using startcast and stopcast

    main

    To create a clean, loopable GIF (e.g., for a README) without the slow startup or final exit, use the startcast and stopcast steps within your program file. This allows you to bracket only the interesting parts of the session.

    Clip Control Steps

    • startcast: Drops all previously captured frames and re-bases the clock to the current moment. It also triggers a window resize to force a full repaint (essential for ratatui apps to ensure the clip doesn't start with a blank grid).
    • stopcast: Finalizes the recording, excluding any subsequent actions (like quitting the app).

    Example Workflow

    1. Use --cols and --rows to drive a smaller terminal size.
    2. Use startcast at the beginning of the 'hero' sequence.
    3. Use stopcast at the end of the sequence.
    4. Use agg to render the resulting cast to a GIF.
  2. Run KDash

    main

    To start the KDash dashboard, simply run the kdash command in your terminal. Ensure your Kubernetes configuration (e.g., ~/.kube/config) is correctly set up in your environment so KDash can connect to your cluster.

    While running, press ? to view the full, always-current list of keybindings, which includes any overrides from your configuration.

    kdash
  3. Configure KDash Themes

    main

    You can cycle through available themes on the fly using the t or Alt+t keys. Supported themes include:

    • Catppuccin Macchiato
    • Catppuccin Latte
    • Gruvbox Dark
    • Solarized Dark
    • Mono
    • Custom themes (if configured)
  4. Install KDash

    main

    KDash can be installed via several package managers depending on your operating system:

    macOS & Linux

    • Homebrew:
      brew tap kdash-rs/kdash
      brew install kdash
    • Arch Linux (AUR): Use an AUR helper like yay or paru to install kdash-bin (prebuilt), kdash (build from source), or kdash-git (latest git main).
    • Install Script (Linux/macOS): Downloads and verifies the latest binary.
      curl -fsSL https://raw.githubusercontent.com/kdash-rs/kdash/main/scripts/install.sh | sh

    Windows

    • Scoop (Recommended):
      scoop bucket add kdash-bucket https://github.com/kdash-rs/scoop-kdash
      scoop install kdash
    • Chocolatey:
      choco install kdash

    Cross-platform / Other

    • Cargo (Rust):
      cargo install kdash
      # If facing k8s-openapi issues:
      cargo install --locked kdash
    • Docker: Run as a container by mounting your KUBECONFIG.
      docker run --rm -it -v ~/.kube/config:/root/.kube/config deepu105/kdash
    • Nix: nix run nixpkgs#kdash
    brew tap kdash-rs/kdash
    brew install kdash
  5. Perform Resource Actions in KDash

    main

    You can manage Kubernetes resources directly from the dashboard using these keybindings:

    KeyAction
    mOpen action menu for the selected resource
    d / yDescribe resource / view YAML
    eEdit resource in your $EDITOR
    Ctrl-dDelete resource (requires confirmation)
    rRollout restart a workload
    sShell into the selected container
    f / Shift+FPort-forward / list and stop active forwards
    xDecode a secret
    cCopy output to the clipboard
  6. Record an asciinema cast with the harness

    main

    You can record the entire driven session as an [asciinema] v2 cast by adding the --cast <path> flag to the harness command. This records the raw PTY bytes, ensuring the recording is a deterministic representation of what the app painted.

    Usage

    /tmp/kdash-uat-venv/bin/python scripts/uat/harness.py \
        scripts/uat/example.prog /tmp/out target/debug/kdash --cast /tmp/out/demo.cast -t 200

    Replaying and Rendering

    • Replay in terminal: asciinema play /tmp/out/demo.cast
    • Render a GIF: agg /tmp/out/demo.cast /tmp/out/demo.gif

    --cast works alongside assertions like expect, refute, and snap.

    /tmp/kdash-uat-venv/bin/python scripts/uat/harness.py \
        scripts/uat/example.prog /tmp/out target/debug/kdash --cast /tmp/out/demo.cast -t 200
    
    # replay in the terminal
    asciinema play /tmp/out/demo.cast      
    # render a GIF (e.g. for the README)
    agg /tmp/out/demo.cast /tmp/out/demo.gif
  7. View and Manage Logs

    main

    KDash provides several ways to interact with container logs:

    • Aggregate Logs: Press Shift+L to view aggregated logs across all pods in a workload.
    • Previous Logs: Press p to view logs from a previously restarted container.
    • Log View Options: While viewing logs, use the following to customize the view:
      • t: Toggle timestamps
      • w: Toggle line wrap
      • s: Toggle auto-scroll
  8. Navigate KDash

    main

    KDash is a keyboard-driven TUI. Use the following keys for navigation:

    KeyAction
    (or k j)Move selection / scroll
    (or h l)Switch resource tab
    Tab / Shift+TabCycle main views forward / back
    EnterSelect row / drill into a resource
    /Filter the current view
    EscGo back / close the current page
    Ctrl-hReset navigation to the root view
    1-0, -Jump straight to a resource tab
    q / Ctrl-cQuit
  9. Configure KDash via YAML

    main

    KDash uses a YAML configuration file for theme overrides, keybindings, and other settings. By default, it looks for a config file at ~/.config/kdash/config.yaml.

    You can specify a custom configuration file path using the KDASH_CONFIG environment variable:

    KDASH_CONFIG=/path/to/config.yaml kdash
  10. Set up the KDash TUI test harness

    main

    The KDash TUI test harness is a Python-based driver used for end-to-end/UAT testing of the KDash terminal UI. It runs kdash in a pseudo-terminal (PTY), simulates keystrokes, and allows for assertions on the rendered screen.

    Requirements

    • Python 3.9+
    • pyte
    • pexpect

    It is recommended to use a virtual environment to avoid polluting your system Python:

    python3 -m venv /tmp/kdash-uat-venv
    /tmp/kdash-uat-venv/bin/pip install pyte pexpect
    python3 -m venv /tmp/kdash-uat-venv
    /tmp/kdash-uat-venv/bin/pip install pyte pexpect
  11. Run the KDash TUI test harness

    main

    To run a test session, you must first build the kdash binary, then execute the harness.py script with a program file (step file), an output directory, and the target binary.

    Command Syntax

    /tmp/kdash-uat-venv/bin/python scripts/uat/harness.py <program> <outdir> [binary] [args...]

    Arguments

    • program: A step file containing the sequence of actions.
    • outdir: The directory where snap: commands will save <label>.txt screenshots.
    • binary: The path to the kdash binary (defaults to target/debug/kdash).
    • args...: Additional CLI arguments passed to kdash (defaults to -t 200).

    Note: The exit code is non-zero if any expect or refute assertions fail, making it suitable for CI pipelines.

    # build first
    cargo build
    
    # run a program file against the debug binary
    /tmp/kdash-uat-venv/bin/python scripts/uat/harness.py <program> <outdir> [binary] [args...]
    
    # example
    /tmp/kdash-uat-venv/bin/python scripts/uat/harness.py \
        scripts/uat/example.prog /tmp/out target/debug/kdash -t 200
  12. Security: Validating kubectl arguments

    main

    To prevent shell injection attacks, KDash validates all arguments passed to kubectl (including resource kind, name, namespace, and context).

    An argument is considered invalid if it contains any of the following characters:

    • Newlines (\n, \r)
    • Null bytes (\0)
    • Shell operators: ;, |, &, `, $, $(, etc.