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

kubectl.sh,bug: possibly broken - run kubectl.sh without having kubectl installed on your machine #1293

Open
dhiller opened this issue Oct 8, 2024 · 14 comments · May be fixed by #1298
Open
Labels
help wanted Identifies an issue that has been specifically created or selected for new contributors. kind/bug

Comments

@dhiller
Copy link
Contributor

dhiller commented Oct 8, 2024

Check whether using kubectl.sh without having kubectl installed on local machine still works.

it used to be the case, a few years back, that you could run kubectl.sh without having kubectl installed on your machine, since the binary would be pulled from the running cluster. At some point that broke, so I resigned myself to installing kubectl on my machine despite not needing it outside of KubeVirt development. If at all feasible, going back to the previous status quo would be very appreciated. Maybe that's already the case and I simply haven't noticed?

Originally posted by @andreabolognani in #1277 (comment)

@dhiller
Copy link
Contributor Author

dhiller commented Oct 8, 2024

/kind bug

/help

@kubevirt-bot
Copy link
Contributor

@dhiller:
This request has been marked as needing help from a contributor.

Guidelines

  • No Barrier to Entry
  • Clear Task
  • Solution Explained
  • Provides Context
  • Identifies Relevant Code
  • Gives Examples
  • Ready to Test
  • Goldilocks priority
  • Up-To-Date

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/kind bug

/help

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-sigs/prow repository.

@kubevirt-bot kubevirt-bot added kind/bug help wanted Identifies an issue that has been specifically created or selected for new contributors. labels Oct 8, 2024
@dhiller
Copy link
Contributor Author

dhiller commented Oct 8, 2024

@dosu explain how kubectl.sh works

@brianmcarey
Copy link
Member

@dosu explain how kubectl.sh works

Is dosubot available on kubevirtci issues?

@dhiller
Copy link
Contributor Author

dhiller commented Oct 8, 2024

Not yet - I've just added it, will try again after indexing has completed.

@dhiller
Copy link
Contributor Author

dhiller commented Oct 8, 2024

@andreabolognani I just did make cluster-up on the latest kubevirt commit with KUBEVIRTCI_PROVIDER=k8s-1.31 set.

When I then did

bash -x ./cluster-up/kubectl.sh get nodes

output showed me

...
+++ kubectl=/home/dhiller/Projects/github.com/kubevirt.io/kubevirt/_ci-configs/k8s-1.31/.kubectl
...

which seems to indicate that it uses the kubectl binary which is copied from the cluster.

So I think we can

/close

this issue. Please chime in if you disagree.

@kubevirt-bot
Copy link
Contributor

@dhiller: Closing this issue.

In response to this:

@andreabolognani I just did make cluster-up on the latest kubevirt commit with KUBEVIRTCI_PROVIDER=k8s-1.31 set.

When I then did

bash -x ./cluster-up/kubectl.sh get nodes

output showed me

...
+++ kubectl=/home/dhiller/Projects/github.com/kubevirt.io/kubevirt/_ci-configs/k8s-1.31/.kubectl
...

which seems to indicate that it uses the kubectl binary which is copied from the cluster.

So I think we can

/close

this issue. Please chime in if you disagree.

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-sigs/prow repository.

@dhiller
Copy link
Contributor Author

dhiller commented Oct 8, 2024

/reopen

Apologies - it seems you were right, since I see here that instead of scping the file from the cluster, it seems it downloads a kubectl binary on the fly in case podman is in use:

curl -Ls "https://dl.k8s.io/release/${k8s_version}/bin/linux/amd64/kubectl" -o ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubectl

FYI @brianmcarey

@kubevirt-bot kubevirt-bot reopened this Oct 8, 2024
@kubevirt-bot
Copy link
Contributor

@dhiller: Reopened this issue.

In response to this:

/reopen

Apologies - it seems you were right, since I see here that instead of scping the file from the cluster, it seems it downloads a kubectl binary on the fly in case podman is in use:

curl -Ls "https://dl.k8s.io/release/${k8s_version}/bin/linux/amd64/kubectl" -o ${KUBEVIRTCI_CONFIG_PATH}/$KUBEVIRT_PROVIDER/.kubectl

FYI @brianmcarey

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-sigs/prow repository.

@dhiller
Copy link
Contributor Author

dhiller commented Oct 9, 2024

@dosu please explain how the script kubectl.sh works

Copy link

dosubot bot commented Oct 9, 2024

The kubectl.sh script operates by executing commands based on the first argument provided:

  1. Environment Setup: It sets the KUBEVIRTCI_PATH if not already set, which is the directory path of the script.

  2. Source Configuration: It sources several configuration scripts:

    • common.sh
    • provider.sh (specific to the KUBEVIRT_PROVIDER)
    • config.sh
  3. Command Execution:

    • If the first argument is console, vnc, start, stop, or migrate, it calls virtctl.sh with all the arguments.
    • If the first argument is virt, it shifts the arguments and calls virtctl.sh with the remaining arguments.
    • For any other arguments, it calls the _kubectl function with all the arguments, which is a wrapper around the kubectl command.

The script is designed to manage virtual machine operations and Kubernetes commands without needing kubectl installed locally, as it can use a binary copied from the cluster or downloaded if Podman is used [1][2].

To continue talking to Dosu, mention @dosu.

@dhiller
Copy link
Contributor Author

dhiller commented Oct 9, 2024

FYI @brianmcarey

@dhiller
Copy link
Contributor Author

dhiller commented Oct 9, 2024

This brings up a fundamental point of kubectl.sh: instead of properly determining whether virtctl is even available it just forwards it. I think what it should do is check whether kubectl virt is available and use that in case the command execution tries to forward to virtctl binary.

@andreabolognani
Copy link

@dhiller I just opened #1298 which seems to make the problem go away for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Identifies an issue that has been specifically created or selected for new contributors. kind/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants