Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab completion breaks if using recommended alias kubectl='minikube kubectl --' #12938

Closed
vcc-huf opened this issue Nov 12, 2021 · 16 comments · Fixed by #14868
Closed

Tab completion breaks if using recommended alias kubectl='minikube kubectl --' #12938

vcc-huf opened this issue Nov 12, 2021 · 16 comments · Fixed by #14868
Labels
cmd/kubectl Issues with the "kubectl" command kind/improvement Categorizes issue or PR as related to improving upon a current feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@vcc-huf
Copy link

vcc-huf commented Nov 12, 2021

  1. install minkube
  2. add alias kubectl='minikube kubectl --' to .bashrc
  3. add source <(kubectl completion bash) to .bashrc

result:
only the commands get tab-completed, nothing after that.

the underlying issue is this:

$ minikube kubectl __completeNoDesc get p
Error: flags cannot be placed before plugin name: --cluster

this works however:

~/.minikube/cache/linux/v1.22.3/kubectl __completeNoDesc get p

related to this: kubernetes/kubectl#884

@afbjorklund
Copy link
Collaborator

You could try making "kubectl" a symlink to "minikube", rather than a bash alias.

@vcc-huf
Copy link
Author

vcc-huf commented Nov 12, 2021

found this workaround. put it in bashrc:

KUBECTL_PATH="$HOME/.minikube/cache/linux/$(minikube kubectl -- version -o json | jq -r '.clientVersion.gitVersion')/kubectl"

kubectl() {
    $KUBECTL_PATH "$@"
}

source <(kubectl completion bash)

@vcc-huf
Copy link
Author

vcc-huf commented Nov 12, 2021

You could try making "kubectl" a symlink to "minikube", rather than a bash alias.

nah, same problem, minikube starts kubectl with --cluster minikube before the completion stuff, and kubectl cant handle that (see the bug i linked).

@medyagh
Copy link
Member

medyagh commented Nov 17, 2021

hm.. that seems like a feature it can't do, I would accept a purposal or a PR that would fix or find a work around for this?

we would need to add the --cluster because the user might have multiple clusters and that had caused our tests to fail

@vcc-huf
Copy link
Author

vcc-huf commented Nov 18, 2021

well, until they fix kubectl, you can maybe provide an official and supported way to directly call the kubectl installed by minikube?
the one i discovered is rather a hack.

@vcc-huf
Copy link
Author

vcc-huf commented Nov 18, 2021

just realized that my hack doesnt work if the minikube node is down... because of reasons.

this does work however:

KUBECTL_PATH="$HOME/.minikube/cache/linux/$(minikube kubectl -- version 2>/dev/null | perl -lne '/GitVersion:"([^"]*)"/ && print $1')/kubectl"

it's even worse though.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 16, 2022
@sharifelgamal sharifelgamal added priority/backlog Higher priority than priority/awaiting-more-evidence. cmd/kubectl Issues with the "kubectl" command kind/improvement Categorizes issue or PR as related to improving upon a current feature. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 16, 2022
@medyagh
Copy link
Member

medyagh commented Apr 13, 2022

just realized that my hack doesnt work if the minikube node is down... because of reasons.

this does work however:

KUBECTL_PATH="$HOME/.minikube/cache/linux/$(minikube kubectl -- version 2>/dev/null | perl -lne '/GitVersion:"([^"]*)"/ && print $1')/kubectl"

it's even worse though.

@vcc-huf is this a good work arround ? if yes you could add it to our website as a tip for other users

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 12, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Aug 11, 2022
@oldium
Copy link
Contributor

oldium commented Aug 28, 2022

Same on Windows actually. The command minikube kubectl is broken with regards to autocomplete (i.e. command __complete) in PowerShell too.

@oldium
Copy link
Contributor

oldium commented Aug 28, 2022

Maybe it would be sufficient to update the following line to simply accept __complete in the same way as --help:

if len(args) > 1 && args[0] != "--help" {

@oldium
Copy link
Contributor

oldium commented Aug 28, 2022

Created PullRequest with the fix, now the __complete request is passed as-is to kubectl.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 27, 2022
@vipseixas
Copy link

just realized that my hack doesnt work if the minikube node is down... because of reasons.

this does work however:

KUBECTL_PATH="$HOME/.minikube/cache/linux/$(minikube kubectl -- version 2>/dev/null | perl -lne '/GitVersion:"([^"]*)"/ && print $1')/kubectl"

it's even worse though.

I had to change this a little to work:

KUBECTL_PATH="$HOME/.minikube/cache/linux/amd64/$(minikube kubectl -- version --client 2>/dev/null | perl -lne '/GitVersion:"([^"]*)"/ && print $1')/kubectl"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/kubectl Issues with the "kubectl" command kind/improvement Categorizes issue or PR as related to improving upon a current feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants