c-bata / kube-prompt

An interactive kubernetes client featuring auto-complete.
MIT License
1.79k stars 134 forks source link

Allow specifying context and namespace as ENV vars or CLI params #12

Open jonmoter opened 6 years ago

jonmoter commented 6 years ago

I have an admin host that has a kubeconfig.yml file with many clusters and contexts configured. The YAML file is shared between many users, so it's read only.

It would be great if I could set an ENV var or pass a command line prompt which would set the default context or namespace of all the commands I run in kube prompt.

Something like:

kube-prompt --context=test-cluster --namespace=default

or

export CONTEXT=test-cluster NAMESPACE=default
kube-prompt

When I use kubectl in my day-to-day, I usually create aliases like:

alias kc="kubectl --context=test-cluster --namespace=default"
kc get pods

So this feature request would allow me to do the equivalent with kube-prompt.

Btw, great utility! Thanks for creating it!

c-bata commented 6 years ago

kube-shell has great solution to fix this problem because toolbar(displays the bottom of terminal) feature provided by python-prompt-toolkit. (this issue is related with https://github.com/c-bata/kube-prompt/issues/5 and https://github.com/c-bata/kube-prompt/issues/6 )

Your suggested option is more easy solution than kube-shell. So if it's difficult to implement toolbar feature in go-prompt, I may choice your suggested solution. Thanks.