derailed / k9s

🐶 Kubernetes CLI To Manage Your Clusters In Style!
https://k9scli.io
Apache License 2.0
27.32k stars 1.71k forks source link

Select the namespace of the selected resource #2334

Open k-harutyunyan opened 11 months ago

k-harutyunyan commented 11 months ago




Is your feature request related to a problem? Please describe. Very often there is a need to select the namespace of the selected resource when you are in the "all namespaces" view to see the related resources.

Describe the solution you'd like It would be helpful to have some command or shortcut to select the namespace of the selected resource..

Describe alternatives you've considered As an alternative you should copy the namespace, go to the namespaces view, filter with the namespace name.

wjiec commented 11 months ago

You can also use :[resource] [namespace](e.g. :po kube-system) to switch directly under a namespace.

k-harutyunyan commented 11 months ago

Thanks, I know the command, but it would be better to have a shortcut like <u> Use in order not to type verbose namespace names, even if there is autocomplete for namespaces in that context.

wjiec commented 11 months ago

@derailed I think we can add alias functionality to the plugin to solve these kinds of problems? the alias plugin for example:

plugin:
    shortCut: Ctrl-U
    alias: "$RESOURCE_NAME $NAMESPACE"
    ...: ...

What do you think of this idea?

k-harutyunyan commented 11 months ago

I added this plugin, it works, but relaunching a new instance of k9s is slow.

  use-ns:
    shortCut: Ctrl-N
    description: Select namespace
    scopes:
      - all
    command: k9s
    background: false
    confirm: false
    args:
      - --context=$CONTEXT
      - --namespace=$NAMESPACE
derailed commented 10 months ago

@k-harutyunyan Right less than ideal ;(

Would the new workload functionality fit that bill?

@wjiec I like the idea, but perhaps volunteering env vars for aliases or hotkeys could be a cool way for folks to parametrize custom commands beside plugins??

wjiec commented 10 months ago

@derailed YES, we can adding environmental variable support on the basis of aliases and hotkeys, offer a more flexible solution to cater to user requirements. This is a better idea. 👍

k-harutyunyan commented 10 months ago

@derailed I tried the new workload functionality, that fits from the other side and is a cool feature. But we need to write the namespace not select it from any resource. I think it will be very helpful to have a shortcut to open the workloads of a resource's namespace, e.g., when debugging, investigating a pod or some other resource from the multiple namespaces view you might want to investigate the related resources under that namespace, and should either go to the namespaces filter for that namespace and select it or write a command with a namespace like wk <ns>, anyway the namespace under the context should be copied or written manually. Thank you guys.