c-bata / kube-prompt Goto Github PK
View Code? Open in Web Editor NEWAn interactive kubernetes client featuring auto-complete.
License: MIT License
An interactive kubernetes client featuring auto-complete.
License: MIT License
In response to #21 and all kube-prompt's users.
After publishing kube-prompt, I'm pleased that many users more than I expected use this. But I don't have enough time and mental energy to reply issues, check PRs and update version of kubernetes/client-go
. So I'm looking for one or more co-maintainers that can help me.
If you are interested, please reply to this issue.
Thanks.
A trivy
scan of the repo indicates that there a few CVE issues with dependencies (likely k8s libraries). Please consider updating the libraries to address the (>= HIGH) vulnerabilities.
+-----------------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+-----------------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+
| github.com/dgrijalva/jwt-go | CVE-2020-26160 | HIGH | 3.2.0+incompatible | v4.0.0-preview1 | jwt-go: access restriction |
| | | | | | bypass vulnerability |
| | | | | | -->avd.aquasec.com/nvd/cve-2020-26160 |
+-----------------------------+------------------+ +-----------------------------------+------------------------------------+---------------------------------------+
| golang.org/x/crypto | CVE-2020-29652 | | 0.0.0-20190820162420-60c769a6c586 | v0.0.0-20201216223049-8b5274cf687f | golang: crypto/ssh: crafted |
| | | | | | authentication request can |
| | | | | | lead to nil pointer dereference |
| | | | | | -->avd.aquasec.com/nvd/cve-2020-29652 |
+ +------------------+ + +------------------------------------+---------------------------------------+
| | CVE-2020-9283 | | | v0.0.0-20200220183623-bac4c82f6975 | golang.org/x/crypto: Processing |
| | | | | | of crafted ssh-ed25519 |
| | | | | | public keys allows for panic |
| | | | | | -->avd.aquasec.com/nvd/cve-2020-9283 |
+-----------------------------+------------------+----------+-----------------------------------+------------------------------------+---------------------------------------+
Release files for v1.0.7 have v1.0.6 in their names
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!
First off, thanks for writing this tool, it looks like it should be pretty helpful. Excited to start using it more.
This is for version 1.0.1:
As you can see below my context is registered to use the seu
namespace by default, but the completions are from the default
namespace. But then when the actual command is run it uses the proper namespace, and therefore can't find my auto completed pod.
>>> get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
...
default canopy-2965694291-f5f6c 1/1 Running 0 1d
default canopy-2965694291-kjbqq 1/1 Running 0 1d
...
seu hello-world-v13-1574404032-4hzxd 1/1 Running 0 62d
...
>>> describe pod
...
canopy-2965694291-f5f6c Running
canopy-2965694291-kjbqq Running
>>> describe pod canopy-2965694291-f5f6c
Error from server (NotFound): pods "canopy-2965694291-f5f6c" not found
Got error: exit status 1
>>> describe pod hello-world-v13-1574404032-4hzx
Name: hello-world-v13-1574404032-4hzxd
Namespace: seu
...
I have 3 different cluster configs, all set in KUBECONFIG. All have different names than just config
kube-prompt fails when I try to get a certain pod or service
>>> get pods panic: stat /Users/tarekmehrez/.kube/config: no such file or directory
goroutine 36 [running]:
github.com/c-bata/kube-prompt/kube.NewClient(0x0)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/client.go:29 +0x140
github.com/c-bata/kube-prompt/kube.getClient(0x0)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/client.go:14 +0x2e
github.com/c-bata/kube-prompt/kube.fetchPods()
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/resource.go:177 +0x72
created by github.com/c-bata/kube-prompt/kube.getPodSuggestions
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/resource.go:183 +0x39
Is there a way that this might work by checking the config files set in the KUBECONFIG
env var?
Thanks
Hello, thanks for this. Is there a way you could support displaying which context is current on the cli please?
It seems that kubectl config rename-context
is not being suggested/autocompleted.
(I will try and see if I can make a merge request tomorrow... didn't look at the code yet - kinda late :))
Thanks to develop this tool which saved me a lot of typing time.
I ask for the feature which I needn't jump out of prompt to run other shell commands, such as ls, find, curl, and even kubectx (k8s cluster switch) and kubens (k8s namespace switch)
For example, I prefer a feature, if I add !
in front of command, it will run shell command, not kubectl command.
>>> ! ls
Please vote this idea, if you like
I don't have kubectl
installed but use alias kubectl='minikube kubectl --'
instead as described in https://minikube.sigs.k8s.io/docs/handbook/kubectl/.
Then I get this error:
$ kube-prompt
kube-prompt v1.0.10 (rev-43bcffa)
Please use `exit` or `Ctrl-D` to exit this program.
>>> help
/bin/sh: 1: kubectl: not found
Got error: exit status 127
>>>
When using the logs
command, it would be nice to also provide init containers via completion. Not sure how active this repo is, but I'd be happy to contribute if PRs are being accepted.
Because the cross build is already supported. Could you upload the Linux-arm64 binary to Github release? So I can use the released binary directly in my project.
kube-prompt is gradually becoming a little bit famous. So perhaps it is the worth to register at a homebrew official repository.
It is a little bit comfortable because we don't need brew tap
.
Today you have to set the namespace when you start the session or specify it each command. It would be create to be able to switch the namespace or even the context while in a session.
Example proposal
!namespace "namespace autocomplete"
!ns "namespace autocomplete"
typing exit or quit doesn't seem to work...
$ kube-prompt
kube-prompt v1.0.6 (rev-298f692)
Please use `exit` or `Ctrl-D` to exit this program.
>>> get pod -n automation-hub
NAME READY STATUS RESTARTS AGE
api-59bf57744b-n9kv4 1/1 Running 0 5d1h
...
>>> -nBye!
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/c-bata/kube-prompt/kube.(*Completer).argumentsCompleter(0xc0002d15e0, 0xc00038e5b2, 0xb, 0xc00032b400, 0x0, 0x2, 0x0, 0x0, 0x0)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/arguments.go:98 +0x8955
github.com/c-bata/kube-prompt/kube.(*Completer).Complete(0xc0002d15e0, 0xc0005b4c6c, 0x3, 0x3, 0x0, 0xffffffffffffffff, 0xc0004bbcf8)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/completer.go:83 +0x38c
github.com/c-bata/kube-prompt/kube.(*Completer).Complete-fm(0xc0005b4c6c, 0x3, 0x3, 0x1c12280, 0xc000398401, 0xc00032b380)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/main.go:35 +0x48
github.com/c-bata/kube-prompt/vendor/github.com/c-bata/go-prompt.(*CompletionManager).Update(0xc00043c820, 0xc0005b4c6c, 0x3, 0x3)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/vendor/github.com/c-bata/go-prompt/completion.go:69 +0x48
github.com/c-bata/kube-prompt/vendor/github.com/c-bata/go-prompt.(*Prompt).Run(0xc000395400)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/vendor/github.com/c-bata/go-prompt/prompt.go:85 +0x625
main.main()
/Users/a14737/go/src/github.com/c-bata/kube-prompt/main.go:41 +0x37a
kube-prompt doesn't support completion for container name.
kubectl logs <pod name> -c <container name>
โ this one
Hi,
Your project seems amazing. Could you publish windows 64bits binaries?
Thx,
To all kube-prompt's users
In public alpha version of gcloud, interactive shell mode is added. This feature provides interactive completion of kubectl's subcommands, not to mention a gcloud's subcommands (See https://cloudplatform.googleblog.com/2018/03/introducing-GCPs-new-interactive-CLI.html
for more details)
Some features still lack but it will be improved in the future (ex: kube-prompt and kube-shell provides feature to complete kubernetes resources such as pods, deployments and so on). It's great news, but it means the worth of kube-prompt will be disappear anymore. Therefore I will not actively develop kube-prompt.
Thanks.
If you only want to use this mode in Bash, an alternative is to use the following in your .bashrc, again with a login/logout or resourcing of the file:
set -o vi
like:
$ kube-prompt
>>> apply --filename ./
completion local yaml files
Does it not record the history of command execution?
I can not found history of previously executed commands.
Hey @c-bata ๐ Thanks so much for kube-prompt.
I use it every day and love it ๐
It'd be nice if it supported the 'Alt' key set of shortcuts from GNU readline.
As most others are already supported (Ctrl+A, Ctrl+E, Ctrl+K, etc.), I figured this would be a reasonable request.
I'd love to contribute myself and submit an MR for this. In fact this is something I wanted to include in my contributions toakavel/up a while back, but couldn't quite work out how to do it.
Perhaps if you can spare a moment, you might be able to hint/point me in the right direction? ๐
I'll have a look over the code and see where I get to, but I wanted to ask first if this is a contribution you'd be happy with?
It would be really cool display yaml output in colors
I think https://github.com/alecthomas/chroma or https://github.com/zyedidia/highlight can be used to colorize
On newly released RPi4, ARM64 support is out of official roadmap. Ubuntu ARM64 for RPi4 is not release yet. Thus we hope to build a binary for ARM32 which could be run on Raspbian system which is officially supported by Raspberry Pi (2, 3 and 4)
Is there a way to exit a --watch
command without exiting the prompt completely?
We get the following error when installing kube-prompt with brew.
$ brew install c-bata/kube-prompt/kube-prompt
Error: c-bata/kube-prompt/kube-prompt: Calling bottle :unneeded is disabled! There is no replacement.
Please report this issue to the c-bata/kube-prompt tap (not Homebrew/brew or Homebrew/core):
/opt/homebrew/Library/Taps/c-bata/homebrew-kube-prompt/kube-prompt.rb:5
seems like kube-prompt can't log to Azure Kubernetes Service (aka AKS). any idea whether this is only configuration to do on my part or is this requires an update (from other k8s related projects, seems it's on the client end to add some package
Hello, I trying kube-prompt with microk8s on Ubuntu 18.04.
I installed microk8s using the following commands:
sudo snap install microk8s --classic
sudo snap alias microk8s.kubectl kubectl
kube-prompt seems to work well, until you invoke a 'describe no' command
>>> get nodes
NAME STATUS ROLES AGE VERSION
hos54985 Ready <none> 6h22m v1.14.2
>>> describe no panic: invalid configuration: no configuration has been provided
goroutine 9 [running]:
github.com/c-bata/kube-prompt/kube.NewClient(0x114f6ff)
/build/go/src/github.com/c-bata/kube-prompt/kube/client.go:28 +0x1ad
github.com/c-bata/kube-prompt/kube.getClient(...)
/build/go/src/github.com/c-bata/kube-prompt/kube/client.go:15
github.com/c-bata/kube-prompt/kube.fetchNodeList()
/build/go/src/github.com/c-bata/kube-prompt/kube/resource.go:464 +0x114
created by github.com/c-bata/kube-prompt/kube.getNodeSuggestions
/build/go/src/github.com/c-bata/kube-prompt/kube/resource.go:470 +0x39
Do you have any idea for how to fix this issue?
Thanks
I cannot navigate through the items of a completion combobox. I was expecting something similar to the interactive mode of az/gcloud/aws-shell.
Anyway that's a really cool tool you have, thanks for sharing !
CHANGELOG is below:
https://github.com/kubernetes/client-go/blob/v6.0.0/CHANGELOG.md
Compatibility matrix of client-go is below:
https://github.com/kubernetes/client-go#compatibility-matrix
I would like to be able to run kube-prompt with something like:
$ kube-prompt --prefix "foo>"
and then be given a prompt with prompt.OptionPrefix
set to foo>
.
This could be useful when running kube-prompt in different contexts to know which one you are in.
Generate suggestions from cobra.Command defined at kubectl:
Currently kube-prompt only imports the gcp
auth helper
Lines 3 to 7 in 584bef9
Please could you also import the oidc
helper with a blank identifier so it is included in the release builds?
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
Although I wonder if you might want to just import support for all of the available auth plugins rather than adding them one-by-one when people request them?
First of all, thanks for the project, this tool is awesome.
I'm using it but from the gifs you provided I understand that it also supports prompting names of actual resources that are available in my cluster. For example if I write "get pods a" it should prompt me all pods that start with "a". Unfortunately it doesn't work for me and I have no idea how to troubleshoot that. Any ideas?
It would be great if when you run
>>> get po -n
You get a list of available namespaces
I have 3 different contexts, all set in KUBECONFIG.
kube-prompt fails when I try to get a certain pod or service
>>> get pods panic: stat /Users/tarekmehrez/.kube/config: no such file or directory
goroutine 36 [running]:
github.com/c-bata/kube-prompt/kube.NewClient(0x0)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/client.go:29 +0x140
github.com/c-bata/kube-prompt/kube.getClient(0x0)
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/client.go:14 +0x2e
github.com/c-bata/kube-prompt/kube.fetchPods()
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/resource.go:177 +0x72
created by github.com/c-bata/kube-prompt/kube.getPodSuggestions
/Users/a14737/go/src/github.com/c-bata/kube-prompt/kube/resource.go:183 +0x39
Is there a way that this might work just by checking my current context?
I think this feature would be very useful when we're working in certain namespace. For example, we would execute kube-prompt --namespace staging
to set default namespace to staging
if not set explicitly in the prompt. So we don't need to type --namespace
option for each commands.
Bonus:
Taking more generic approach, it would be better if kube-prompt
CLI accept options from original kubectl
command as defaults. For example, executing kube-prompt --namespace dev -o wide
sets default namespace to dev
and output format to wide
for any compatible commands. (i.e. it behaves like currying/partial application in functional programming)
I noticed that when I try to start kube-prompt and my current context has a user that is not allowed to list all namespaces that it prompts me the fallowing error:
error namespaces is forbidden: User "system:serviceaccount:<name>:<another-name>" cannot list namespaces at the cluster scope
However, kube-prompt works just fine when I switch to a user without namespace list right from a user with those rights.
Is good idea to implement watch feature ;)
Would be nice to have the colors configurable.
I'm using black on white terminal and the yellow prompt is hardly readable for me.
Hi there,
We developed a web based kubectl tool, which enables you to manage kubernetes credentials and run kubectl command in web browser.
https://github.com/webkubectl/webkubectl
Hopefully it's useful for you guys.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.