✅ How to Use fzf with Kubernetes
Here are some powerful ways to combine fzf with kubectl:
1. Get Pods and Inspect One
-
You’ll interactively pick a pod.
-
Then
kubectl describewill show its details.
2. Exec into a Pod (Select with fzf)
-
Launches a bash shell into the selected pod (if it supports bash).
3. List Namespaces and Switch
-
Outputs a list of namespaces to select from.
To switch context (assuming a helper function):
4. Use Aliases or Functions in Shell
Add to your .bashrc or .zshrc:
Then run kpod to trigger the interactive workflow.
5. Kube Tools with Built-in Fuzzy Support
Some CLI tools already integrate fzf:
🧰 k9s
-
Terminal UI for managing Kubernetes.
-
Has built-in fuzzy search.
-
Fully interactive.
🧰 kubectx and kubens
-
kubectx | fzflets you fuzzy-pick a context to switch. -
kubens | fzffor namespace switching.
🔄 Combining Tools for Better UX
You can pipe commands together:
Or create custom interactive dashboards using fzf, kubectl, and shell functions.
✅ Bash/Zsh Function
Lists all namespaces using
kubectl get ns.-
Lets you select a namespace using
fzf. -
Lists pods in that namespace.
-
Lets you select a pod using
fzf. -
Runs
kubectl describe podon the selected pod.
Add this to your ~/.bashrc or ~/.zshrc:
Then reload your shell:
💡 Usage
Simply type:
And follow the interactive prompts to:
-
Choose a namespace
-
Choose a pod
-
View detailed description (
kubectl describe podoutput)
No comments:
Post a Comment