You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a custom function which lets you easily switch between contexts and namespaces in Kubernetes. It's still a work in progress as kubectl has some weird behaviours and error handling is a bit cumbersome. Nevertheless i want to share a first version here.
## fzf k8s function# __________________________#function_fzf_k8s_ctx_nsif not type -q kubectl
set_color red
echo"_fzf_k8s_ctx_ns: kubectl not found.">&2
set_color normal
return 1
end
set ctx (
kubectl config get-contexts --no-headers=true |
awk '{print $2}'|
_fzf_wrapper --query=(commandline --current-token) $fzf_shell_vars_opts
)
command kubectl cluster-info 1> /dev/null
iftest$status -ne 0
return$status
end
iftest$status -eq 0
command kubectl config use-context $ctx1> /dev/null
end
set ns (
kubectl get namespaces --no-headers=true |
awk '{print $1}'|
_fzf_wrapper --query=(commandline --current-token) $fzf_shell_vars_opts
)
iftest$status -eq 0
command kubectl config set-context --current --namespace $ns1> /dev/null
end
commandline --function repaint
end
Once defined you can bind the function to keys of your preference.
functionfish_user_key_bindingsbind\ck _fzf_k8s_ctx_ns # Ctrl-k
end
Known issues:
If connection error occurs after kubectl cluster-info an additional ENTER is required to exit.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm working on a custom function which lets you easily switch between contexts and namespaces in Kubernetes. It's still a work in progress as
kubectl
has some weird behaviours and error handling is a bit cumbersome. Nevertheless i want to share a first version here.Once defined you can bind the function to keys of your preference.
Known issues:
kubectl cluster-info
an additionalENTER
is required to exit.Beta Was this translation helpful? Give feedback.
All reactions