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

Support installing kubectl #1502

Open
tamalsaha opened this issue Apr 22, 2020 · 15 comments
Open

Support installing kubectl #1502

tamalsaha opened this issue Apr 22, 2020 · 15 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@tamalsaha
Copy link
Contributor

What would you like to be added:
It will be useful if kind could also kubectl, kustomize etc.

Why is this needed:
kubectl, etc. needs to match the version of k8s. Right now, it is a clumsy manual process and kind of pain to add in a CI env.

Something like https://github.com/nutellinoit/kubenvz could be built into kind, it will be even more awesome.

@tamalsaha tamalsaha added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 22, 2020
@BenTheElder
Copy link
Member

I tend to use https://github.com/GoogleCloudPlatform/kubectl-dispatcher installed via gcloud components install kubectl as my system kuebctl, it automatically dispatches over multiple versions so you don't have to keep reinstalling.

I'm not sure how we should best match this into kind though, especially since kind is meant to support completely arbitrary k8s commits.

@seans3 is it feasible to drop binaries for specific commits in some directory and have the dispatcher match as closely as possible?

the node images do have kubectl, on linux you can just copy it out to the host with a one-liner, but mac / windows are problematic.

@BenTheElder BenTheElder added the kind/design Categorizes issue or PR as related to design. label Apr 22, 2020
@seans3
Copy link

seans3 commented Apr 22, 2020

The kubectl-dispatcher currently only matches the version major/minor, falling back to the dispatcher's default version.

Some background: the kubectl dispatcher is kubectl with a simple query/dispatch happening before every kubectl command. The kubectl dispatcher asks the APIServer what version it is, then it executes a version of kubectl (in the same directory) that has the same major/minor version. This version is named kubectl.<MAJOR>.<MINOR>. Example: kubectl.1.15. If the kubectl dispatcher does not find this versioned kubectl, it just drops through to execute at it's default version. This is what the kubectl/gcloud distribution looks like:

$ ls -l /usr/local/google-cloud-sdk/bin/kubectl*
-rwxr-xr-x 1 sean sean 43086784 Feb  5 19:29 /usr/local/google-cloud-sdk/bin/kubectl
-rwxr-xr-x 1 sean sean 39271904 Oct 15  2019 /usr/local/google-cloud-sdk/bin/kubectl.1.13
-rwxr-xr-x 1 sean sean 43119424 Dec 11 05:11 /usr/local/google-cloud-sdk/bin/kubectl.1.14
-rwxr-xr-x 1 sean sean 42993696 Jan 18 16:08 /usr/local/google-cloud-sdk/bin/kubectl.1.15
-rwxr-xr-x 1 sean sean 42889216 Jan 18 16:04 /usr/local/google-cloud-sdk/bin/kubectl.1.16
-rwxr-xr-x 1 sean sean 43491328 Jan 18 16:03 /usr/local/google-cloud-sdk/bin/kubectl.1.17

@BenTheElder to answer your question about dropping binaries into a location: it would have to look like this previous organization. It requires a special kubectl with the dispatch mechanism, and it requires versioned kubectl binaries named according to the convention in the same directory as the kubectl dispatcher.

@seans3
Copy link

seans3 commented Apr 22, 2020

@BenTheElder Please let me know how I can help. I can probably put a kubectl dispatcher tarball in a google cloud bucket for download.

@BenTheElder
Copy link
Member

thanks, I think we might need to consider also placing it somewhere like github, kind is generally workable in china and has an active userbase there but we've found with our nightly builds that GCS cannot be reached behind GFW.

how would the dispatcher to tiebreak kubectl1.15.5 and kubectl1.15.5-something binaries if we drop more in there?

also not sure how we avoid infinite versions.

maybe we focus on installing release versions and just assume that the api is not supposed to break in 1.X. across all ...

@BenTheElder
Copy link
Member

I'm not sure when we'll get to this with some other big changes still settling but I really like this idea, this has been a fairly major pain point for me as well.

I'm going to sync with seans3 soon to discuss what it might look like to support installing the dispatcher (and installing more kubectl binaries) because I think that's the least friction way to go, you wouldn't need to switch between versions manually, just make sure they're installed and then it just matches the server :-)

@BenTheElder BenTheElder self-assigned this Apr 28, 2020
@BenTheElder BenTheElder added this to the 2020 goals milestone Apr 28, 2020
@BenTheElder BenTheElder added the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Apr 28, 2020
@tamalsaha
Copy link
Contributor Author

Similar tools for Helm
https://github.com/tokiwong/helm-switcher

@afbjorklund
Copy link
Contributor

We have this in minikube kubectl, which was inspired by microk8s.kubectl.

https://github.com/kubernetes/minikube/blob/master/cmd/minikube/cmd/kubectl.go

Basically we download the correct version to the cache and run it from there.

Here's another nice approach: https://apps.0install.net/kubernetes/kubectl.xml

@aojea
Copy link
Contributor

aojea commented Jun 3, 2020

kind has the kubectl binary inside the node image, and it matches the other kubernetes componentes in the node

 docker exec -it kind-control-plane /usr/bin/kubectl version --kubeconfig /etc/kubernetes/admin.conf
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-30T20:18:51Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-30T20:19:45Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

a quick hack

aojea@host:~/go/src/sigs.k8s.io/kind$ export KUBECTL="docker exec -it kind-control-plane /usr/bin/kubectl --kubeconfig /etc/kubernetes/admin.conf"
aojea@host:~/go/src/sigs.k8s.io/kind$ $KUBECTL get services
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   fd00:10:96::1   <none>        443/TCP   90m

@tao12345666333
Copy link
Member

Usually, I will directly copy kubectl to the local after using KIND to start the cluster

(MoeLove) ➜  ~ docker cp kind-control-plane:/kind/bin/kubectl ~/bin/kubectl
(MoeLove) ➜  ~ ~/bin/kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-30T20:18:51Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-30T20:19:45Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

@BenTheElder
Copy link
Member

That only works on Linux @aojea @tao12345666333.

We can pretty easily do something like minikube kubectl, however I think the dispatcher is preferable so as to correctly handle multiple contexts & versions without reinventing the wheel.

The biggest trick to consider is that we support unreleased kubernetes versions / arbitrary commits. We'll also need to improve the dispatcher hosting, and determine where to install this on the host.

@aojea
Copy link
Contributor

aojea commented Jun 6, 2020

That only works on Linux @aojea @tao12345666333.

We can pretty easily do something like minikube kubectl, however I think the dispatcher is preferable so as to correctly handle multiple contexts & versions without reinventing the wheel.

The biggest trick to consider is that we support unreleased kubernetes versions / arbitrary commits. We'll also need to improve the dispatcher hosting, and determine where to install this on the host.

Can we wrap with kind the inner kubectl?
kind kubectl --name kind-cluster ...

@BenTheElder
Copy link
Member

BenTheElder commented Jun 8, 2020 via email

@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 Sep 6, 2020
@BenTheElder BenTheElder added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 12, 2020
@kubernetes-sigs kubernetes-sigs deleted a comment from fejta-bot Sep 12, 2020
@BenTheElder BenTheElder modified the milestones: 2020 goals, 2021 goals Jan 25, 2021
@BenTheElder BenTheElder removed their assignment Jun 24, 2021
@BenTheElder BenTheElder added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Jun 24, 2021
@MadhavJivrajani
Copy link

/remove-kind design
/kind feature
kind/design is migrated to kind/feature, see kubernetes/community#6144 for more details

@k8s-ci-robot k8s-ci-robot removed the kind/design Categorizes issue or PR as related to design. label Oct 11, 2021
@BenTheElder
Copy link
Member

Hi, this label was only supposed to be migrated for kubernetes/kubernetes. Please see: https://groups.google.com/g/kubernetes-dev/c/f6W68eS8xo0

@BenTheElder BenTheElder added the kind/design Categorizes issue or PR as related to design. label Oct 11, 2021
@BenTheElder
Copy link
Member

Eh, whatever 🤷‍♂️

@BenTheElder BenTheElder removed the kind/design Categorizes issue or PR as related to design. label Oct 11, 2021
@BenTheElder BenTheElder removed this from the 2021 goals milestone Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

8 participants