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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve k0sctl init usefulness by accepting a list of addresses #136

Merged
merged 11 commits into from
May 5, 2021

Conversation

kke
Copy link
Contributor

@kke kke commented Apr 30, 2021

Trying to make k0sctl init a bit more useful and the output actually to be usable as-is when you provide some bits of data.

Addresses can be set via k0sctl init address1 address2 address3 or via stdin: somecommand | k0sctl init.

The addresses can be:

  • just an address
  • user@address
  • address:ssh_port
  • user@address:ssh_port

With the parameter --controller-count you can set how many of those hosts are going to be controllers. An alternative would be to use something like --controllers="address1,address2,..." --workers="address3,address4.." but that would then be difficult if stdin is accepted 馃 .

The keypath, default user and cluster name can be set via flags.

Example:

$ $ go run . init --user admin --cluster-name k0s-r0x --key-path ~/.ssh/id_rsa 10.0.0.1 10.0.0.2:8022 upuntu@10.0.0.3:9022

==>

apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
  name: k0s-r0x
spec:
  hosts:
  - ssh:
      address: 10.0.0.1
      user: admin
      port: 22
      keyPath: /Users/kimmo/.ssh/id_rsa
    role: controller
    os: ""
  - ssh:
      address: 10.0.0.2
      user: admin
      port: 8022
      keyPath: /Users/kimmo/.ssh/id_rsa
    role: worker
    os: ""
  - ssh:
      address: 10.0.0.3
      user: upuntu
      port: 9022
      keyPath: /Users/kimmo/.ssh/id_rsa
    role: worker
    os: ""
  k0s:
    version: 1.21.0+k0s.0

@kke kke marked this pull request as draft April 30, 2021 08:10
@kke kke requested review from a team, ncopa, trawler and jnummelin and removed request for a team April 30, 2021 08:11
@kke
Copy link
Contributor Author

kke commented Apr 30, 2021

Fishing for thoughts at this point, not actual reviews unless you think it's already good as is.

@ncopa
Copy link
Contributor

ncopa commented Apr 30, 2021

I like this idea. I think that we don't really need to worry about stdin support if we have the options as k0sctl init [options] [ADDRESS...] since you can use xargs. For example:

sh get-ip-addr-list.sh | xargs k0sctl --user admin --key-path=~/.ssh/id_rsa

which would be equivalent to:

sh get-ip-addr-list.sh > /tmp/list
k0sctl --user admin --key-path=~/.ssh/id_rsa $(cat /tmp/list)

I also prefer the --controller-count=3 style over --controllers=$ip1,$ip2,$ip3

@kke kke requested a review from a team May 4, 2021 09:49
@kke kke marked this pull request as ready for review May 4, 2021 09:49
@kke kke changed the title [RFC] Accept address list and extra args in k0sctl init Improve k0sctl init usefulness by accepting a list of addresses May 4, 2021
README.md Outdated Show resolved Hide resolved
Co-authored-by: Natanael Copa <ncopa@mirantis.com>
@kke kke merged commit f35aff0 into main May 5, 2021
@kke kke deleted the init-improvements branch May 5, 2021 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants