A kubectl plugin for tailing logs from Kubernetes pods with continuous discovery.
- Interactive TUI Mode with minimalist terminal interface (default)
- Borderless, full-screen log view with optional sidebar (press
s) - Sidebar uses simple vertical line divider when visible
- Real-time log streaming with color-coded prefixes
- Search with highlighting (
/) and n/N navigation - Separate filter (
f) to show only matching lines (works on buffer) - Pod/container toggling to control which logs to display (in sidebar)
- Status bar showing stats and help hint ("? for help")
- Help overlay with keyboard shortcuts (press
?, fully opaque for easy reading)
- Borderless, full-screen log view with optional sidebar (press
- Multi-cluster support - tail logs across multiple Kubernetes clusters simultaneously
- Tail logs from pods with automatic discovery of new pods
- Support for multiple resources (e.g., several deployments) and various resource types (pods, deployments, statefulsets, daemonsets, jobs, etc.)
- Filter by namespace, labels, and resource names
- Colorized output for easy log differentiation
- Continuous monitoring with graceful handling of pod restarts and deletions
- Memory-bounded ring buffer to prevent unbounded growth
- Backward compatible stdout mode (
--no-tuiflag) - Requires at least one resource or label selector to prevent accidental whole-namespace tailing
- Rust (latest stable version)
- kubectl configured to access your Kubernetes cluster
Install directly from the GitHub repository:
cargo install --git https://github.com/ndenev/kubectl-tail.gitMake sure ~/.cargo/bin is in your PATH.
-
Clone the repository:
git clone https://github.com/ndenev/kubectl-tail.git cd kubectl-tail -
Build the project:
cargo build --release
-
Install the plugin:
cp target/release/kubectl-tail /usr/local/bin/
Or add it to your PATH.
-
Make sure the binary is executable:
chmod +x /usr/local/bin/kubectl-tail
kubectl-tail [OPTIONS] [RESOURCES]...-n, --namespace <NAMESPACE>: Specify the default namespace (default: default)-l, --selector <SELECTOR>: Label selector for pods-c, --container <CONTAINER>: Container name to tail (if multi-container pod)--context <CONTEXT>: Kubernetes context to use (single value - for multi-cluster use resource format)--tail <TAIL>: Number of lines to show from the end of the logs on startup (-1 for all, 0 for none, default: follow from end)-v, --verbose: Enable verbose output for retry messages and pod events-g, --grep <GREP>: Filter logs by regex pattern (stdout mode only)--no-tui: Disable TUI mode and use stdout output (automatically enabled when piping/redirecting)--buffer-size <SIZE>: Maximum buffer size for log messages in TUI mode (default: 10000)
Resources can be specified in multiple formats for flexible multi-namespace and multi-cluster tailing:
name- Pod name (uses default namespace)kind/name- Resource type and name (e.g.,deployment/web)namespace/kind/name- Namespace, resource type, and name (e.g.,production/deployment/api)context/namespace/kind/name- Full path across clusters (e.g.,prod-us/default/deployment/web)
Rules:
- If
--contextor--namespaceflags are used, resource specs cannot override them - If no flags are specified, you can use any format including full 4-part paths
- Contexts must exist in your kubeconfig (validated at startup)
- Resources/namespaces that don't exist at startup won't cause failure - the tool will wait for them to appear
Note:
- TUI mode is automatically disabled when stdout is not a terminal (e.g., when piping to another command or redirecting to a file). You don't need to specify
--no-tuiin these cases. - In TUI mode, debug logs are written to
/tmp/kubectl-tail.logto avoid corrupting the display. Usetail -f /tmp/kubectl-tail.logto monitor logs while using the TUI.
Tail logs from pods with a specific label:
kubectl-tail -l app=nginxTail logs from a deployment:
kubectl-tail deployment/my-deploymentTail logs from multiple deployments:
kubectl-tail deployment/app1 deployment/app2Tail logs from a specific pod:
kubectl-tail my-podTail logs from a specific container in a pod:
kubectl-tail my-pod -c appTail logs in a specific namespace:
kubectl-tail -n production deployment/my-deploymentTail logs from multiple namespaces:
kubectl-tail default/deployment/web staging/deployment/api production/deployment/workersMulti-cluster tailing (full path format):
kubectl-tail prod-us/default/deployment/web prod-eu/default/deployment/apiMix namespaces with default:
kubectl-tail -n production deployment/api staging/deployment/canaryPipe to grep (TUI automatically disabled):
kubectl-tail deployment/my-app | grep ERRORForce stdout mode even when running in a terminal:
kubectl-tail --no-tui deployment/my-appWhen running in TUI mode (default), the following keyboard shortcuts are available:
General:
q/Q/Ctrl-C- Quit the application?- Toggle help overlay (hint shown in status bar)s- Toggle sidebar visibility (off by default)p- Pause/Resume log streamingc- Clear log buffera- Toggle auto-scroll (automatically scroll to bottom)t- Toggle timestampsx- Toggle pod/container prefix display
Navigation:
↑/↓- Navigate sidebar (when open) or scroll logsPgUp/PgDn- Page up/down in logsHome/Endorg/G- Jump to top/bottom of logs (vim-style)Space- Toggle pod/container on/off or expand/collapse tree node (in sidebar)
Search & Filter:
/- Start search (highlights matches in yellow, press Enter to apply)n/N- Jump to next/previous search matchf- Filter buffer (show only matching lines, press Enter to apply)Esc- Cancel search/filter input
Note: Search works on the currently filtered view. You can filter first (e.g., show only ERROR lines), then search within those filtered results.
kubectl-tail collects label selectors from the specified resources and continuously watches for pods across multiple namespaces and clusters. It spawns log tailing tasks for matching running pods and automatically starts tailing new pods that match the selectors (e.g., from scaling deployments).
Resilient Startup: The tool won't fail if resources or namespaces don't exist at startup - it will continuously watch and automatically start tailing when they appear. Only invalid contexts will cause startup failures.
TUI Mode (default):
- Displays logs in a clean, minimalist terminal interface
- Borderless full-screen log view for maximum content visibility
- Optional sidebar (press
s) with vertical line divider showing discovered pods/containers - Interactive checkboxes to toggle pod/container log visibility
- Real-time log streaming with color-coded cluster/pod/container prefixes
- Memory-bounded ring buffer to prevent unbounded growth (default: 10,000 lines)
- Status bar shows live statistics, active filters, and help hint
- Interactive search with multiple modes and keyboard-driven navigation
Multi-cluster & Multi-namespace Support:
Using the resource path format (context/namespace/kind/name), kubectl-tail can connect to multiple clusters and namespaces simultaneously, streaming logs with cluster/namespace/pod/container-prefixed identifiers. This is useful for monitoring distributed applications across multiple Kubernetes clusters and environments in a single view.
Pods are color-coded for easy identification, and tailing stops gracefully when pods are deleted or become non-running.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.