kubermatic / kubeone

Kubermatic KubeOne automate cluster operations on all your cloud, on-prem, edge, and IoT environments.
https://kubeone.io
Apache License 2.0
1.38k stars 234 forks source link

KubeOne as kubectl plugin #993

Closed scheeles closed 2 years ago

scheeles commented 4 years ago

What feature would you like to be added? Provide kubeone as an plugin for kubectl and make it available via https://github.com/kubernetes-sigs/krew-index

What are use cases of the feature? Easy to install and update kubeone

shibumi commented 3 years ago

@scheeles I have played around a bit and I renamed kubeone to kubectl-kubeone and moved it to $HOME/.local/bin/kubectl-kubeone.

This works already surprisingly well:

❯ kubectl kubeone --help
Provision and maintain Kubernetes High-Availability clusters with ease

Usage:
  kubeone [flags]
  kubeone [command]

Available Commands:
  apply       Reconcile the cluster
  completion  Generates completion scripts for bash and zsh
  config      Commands for working with the KubeOneCluster configuration manifests
  document    Generates documentation
  help        Help about any command
  install     Install Kubernetes
  kubeconfig  Download the kubeconfig file from master
  proxy       Proxy to the kube-apiserver using SSH tunnel
  reset       Revert changes
  status      Status of the cluster
  upgrade     Upgrade Kubernetes
  version     Display KubeOne version

Flags:
  -c, --credentials string              File to source credentials and secrets from
  -d, --debug                           debug output with stacktrace
  -h, --help                            help for kubeone
  -m, --manifest string                 Path to the KubeOne config (default "./kubeone.yaml")
  -t, --tfjson terraform output -json   Source for terraform output in JSON - to read from stdin. If path is a file, contents will be used. If path is a dictionary, terraform output -json is executed in this path
  -v, --verbose                         verbose output

Use "kubeone [command] --help" for more information about a command.

What is missing is just putting kubeone into the krew-index and maybe verifiying if all flags are working.

So what is missing for a kubectl kubeone plugin? I investigated a little bit and everything what is missing for this issue is providing a plugin yaml file and adding it via PR on https://github.com/kubernetes-sigs/krew-index

Furthermore you need to consider this dev guide here: https://krew.sigs.k8s.io/docs/developer-guide/

Such a plugin could look like this:

apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
  name: kubeone
spec:
  version: v1.1.0
  platforms:
  - selector:
      matchLabels:
        os: darwin
        arch: amd64
    uri: https://github.com/kubermatic/kubeone/releases/download/v1.1.0/kubeone_1.1.0_darwin_amd64.zip
    sha256: "CHANGEME"
    bin: ./kubectl-kubeone
  - selector:
      matchLabels:
        os: linux
        arch: amd64
    uri: https://github.com/kubermatic/kubeone/releases/download/v1.1.0/kubeone_1.1.0_linux_amd64.zip
    sha256: "CHANGEME"
    bin: ./kubectl-kubeone
  - selector:
      matchLabels:
        os: windows
        arch: amd64
    uri: "TODO"
    sha256: "CHANGEME"
    bin: ./kubectl-kubeone.exe
  shortDescription: Kubermatic KubeOne automate cluster operations on all your cloud, on-prem, edge, and IoT environments
  homepage: https://github.com/kubermatic/kubeone
  caveats: ""
  description: Kubermatic KubeOne automate cluster operations on all your cloud, on-prem, edge, and IoT environments

Here is a roadmap for you guys:

The last step should be automateble via Github Actions ;)

nerdeveloper commented 2 years ago

Please @kron4eg add release tar.gz as an additional compression method to zip. Please refer to the failed build due to this https://github.com/kubernetes-sigs/krew-index/runs/4040884956?check_suite_focus=true

I tried pushing compressing the binary to tar.gz, get the checksum, and pushed to a public GCS: https://storage.googleapis.com/kops-obinna/kubernetes/kubeone.tar.gz and it installed with no hassle

Screenshot 2021-10-29 at 01 24 41
kron4eg commented 2 years ago

@nerdeveloper I don't think the problem is in zip format. I just installed locally using --manifest from your PR that uses zip file.

On the other hand, the fail looks quite strange to me:

    W1028 23:14:55.719584    1943 install.go:164] failed to install plugin "kubeone": install failed: failed to unpack into staging dir: failed to unpack the plugin archive: failed to extract file: can't create file in zip destination dir: open /tmp/krew-downloads861794954/addons/backups-restic/README.md: no such file or directory
    F1028 23:14:55.719631    1943 root.go:77] open /tmp/krew-downloads861794954/addons/backups-restic/README.md: no such file or directory
xmudrii commented 2 years ago

@nerdeveloper I tested it locally as well and it works with the zip archive. I recommend trying to retest the PR or pushing a new commit to retrigger tests, and if that doesn't work, pinging the maintainers to take a look.

xmudrii commented 2 years ago

@nerdeveloper @kron4eg After discussion with Krew maintainers, we concluded that KubeOne wouldn't be a suitable kubectl plugin. The Krew index accepts plugins that manipulate Kubernetes resources, as that's the purpose of kubectl itself. I recommend checking https://github.com/kubernetes-sigs/krew-index/pull/1701 for more details.

I see three possible approaches:

1) do nothing 2) create a custom Krew plugin index — in my opinion, this doesn't seem worth the effort 3) integrate with package managers (e.g. brew, snap) — for example, we already have the KubeOne package in the Arch Linux repos, but I'm not sure are there any stats on how much is it used

If you think approach 2 or 3 would be useful, please create a ticket and we can discuss it there. I'm going to close this issue for now. /close

kubermatic-bot commented 2 years ago

@xmudrii: Closing this issue.

In response to [this](https://github.com/kubermatic/kubeone/issues/993#issuecomment-958756382): >@nerdeveloper @kron4eg After discussion with Krew maintainers, we concluded that KubeOne wouldn't be a suitable kubectl plugin. The Krew index accepts plugins that manipulate Kubernetes resources, as that's the purpose of kubectl itself. I recommend checking https://github.com/kubernetes-sigs/krew-index/pull/1701 for more details. > >I see three possible approaches: > >1) do nothing >2) create a custom [Krew plugin index](https://krew.sigs.k8s.io/docs/developer-guide/custom-indexes/) — in my opinion, this doesn't seem worth the effort >3) integrate with package managers (e.g. brew, snap) — for example, we already have the KubeOne package in the Arch Linux repos, but I'm not sure are there any stats on how much is it used > >If you think approach 2 or 3 would be useful, please create a ticket and we can discuss it there. I'm going to close this issue for now. >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
shibumi commented 2 years ago

integrate with package managers (e.g. brew, snap) — for example, we already have the KubeOne package in the Arch Linux repos, but I'm not sure are there any stats on how much is it used

Hello @xmudrii I had a look on our Arch Linux package stats. Right now, we have 17061 users exposing these statistics and 12 people have kubeOne installed on their system. If I count myself in (who is not exposing statistics on his systems) we have: 17062 users and 13 KubeOne installations.

This is a popularity of ~ 0.1%

We do not know the absolute numbers of all Arch Linux installations/setups world wide. The website ostoday (https://ostoday.org/android/how-many-users-does-arch-linux-have.html) estimates a user count of 4,800,000 users.

This number is little bit pessimistic, but let's calculate with this.

If we have 4,800,000 users we can estimate that we have (according to our statistics) 0.1% KubeOne users. This means, that 4,800 users world wide use KubeOne on Arch Linux.

(Personally, I think the Arch Linux community is much bigger. We are the biggest Linux Reddit community world wide.. etc. Hence, the absolute numbers of KubeOne users on Arch Linux would be bigger).