LinuxCommandLibrary

kube-fzf

Quickly find and select Kubernetes resources

TLDR

Get pod details (from current namespace)

$ findpod
copy

Get pod details (from all namespaces)
$ findpod -a
copy

Describe a pod
$ describepod
copy

Tail pod logs
$ tailpod
copy

Exec into a pod's container
$ execpod [shell_command]
copy

Port-forward a pod
$ pfpod [port_number]
copy

SYNOPSIS

kubectl fzf [options] [resource_type]

Examples:
kubectl fzf pod
kubectl fzf ns
kubectl fzf -x
kubectl fzf --context-only

PARAMETERS

-x, --all-namespaces
    Search across all namespaces for resources.

-c, --context-only
    Interactively select only a Kubernetes context.

-n, --namespace-only
    Interactively select only a namespace.

-p, --pod-only
    Interactively select only a pod.

-r <type>, --resource-type=<type>
    Specify a particular Kubernetes resource type to list and select (e.g., deploy, svc, ing).

-s <labels>, --selector=<labels>
    Filter resources by label selector (e.g., 'app=my-app').

-l, --log
    Directly view logs for the selected pod after selection.

-e, --exec
    Directly execute into the selected pod after selection.

--no-header
    Do not show the header line in the fzf output.

--reverse
    Display fzf results in reverse order (bottom-up).

--preview
    Show a preview window displaying details (e.g., kubectl describe) for the currently highlighted resource in fzf.

--help
    Display the help message and exit.

DESCRIPTION

kube-fzf is a powerful kubectl plugin that streamlines interaction with Kubernetes clusters by integrating the fzf fuzzy finder. It allows users to quickly select and act upon various Kubernetes resources such as contexts, namespaces, pods, deployments, services, ingresses, and more, through an interactive command-line interface.

Instead of typing long kubectl commands, users can simply launch kubectl fzf, search for the desired resource using fzf's fuzzy matching capabilities, and then apply standard kubectl actions (e.g., describe, logs, exec) to the selected item. This significantly enhances productivity and reduces errors when working with complex or multiple Kubernetes environments.

CAVEATS

kube-fzf requires fzf to be installed and available in your system's PATH. It also relies on kubectl being correctly configured to access your Kubernetes clusters. Its exact behavior and available options can vary slightly depending on the specific version or how it was installed (e.g., via krew or as a standalone script).

INSTALLATION

kube-fzf is commonly installed via krew (a kubectl plugin manager) by running kubectl krew install fzf. Alternatively, you can manually download the script or compiled binary from its GitHub repository and place it in your system's PATH to be invoked directly as kube-fzf, or symlink it to kubectl-fzf for kubectl plugin invocation.

INTERACTIVE ACTIONS

Beyond just listing and selecting resources, kube-fzf often allows for chaining interactive actions. For instance, after selecting a pod, you might be presented with additional options to describe, view logs, exec into it, or even delete it, enhancing the interactive workflow significantly.

CUSTOMIZATION

Many implementations of kube-fzf allow for customization via environment variables or configuration files. This enables users to define default behaviors, pass specific fzf options, or configure which Kubernetes resource types should be included or excluded from the fuzzy search.

HISTORY

kube-fzf emerged as a community-driven tool to enhance the kubectl experience, leveraging the power of the fzf fuzzy finder. Its development gained traction due to the growing complexity of managing multiple Kubernetes clusters and numerous resources, making a fuzzy-finding interface highly desirable for efficiency. It's often distributed as a shell script or a compiled binary, popular among developers and operations teams who frequently interact with Kubernetes environments.

SEE ALSO

fzf(1), kubectl(1), krew(1), k9s(1)

Copied to clipboard