alexellis / alexellis/k3sup

[Enhancement] Suggest join commands after successfully completing `k3sup install`

未关闭
#358 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
7.4k
派生
430
PR 合并指标
30 天内没有已合并 PR

描述

## Expected Behaviour
Once a user successfully completes a `k3sup install` command, offer a couple other helpful "next step" commands for joining other nodes (both control plane and worker). This is a minor change to the output but could be helpful, similar to what `kubeadm` provides, to speed the process should a user want to join other nodes. The suggested commands can also be adaptive to the initial input. For example, if `k3sup install` was run with the flag `--k3s-extra-args` then the suggested next commands could include this flag and its arguments.

For example, one suggested output may look like (including current output as of 0.11.0:

```
$ k3sup install --ip 192.168.1.143 --user chip --cluster --tls-san 192.168.1.140 --k3s-channel=stable --k3s-extra-args "--disable traefik --disable servicelb --flannel-backend none --disable-network-policy"
Running: k3sup install
2021/11/23 08:46:41 192.168.1.143
Public IP: 192.168.1.143
[INFO] Finding release for channel stable
[INFO] Using v1.21.5+k3s2 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.21.5+k3s2/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.21.5+k3s2/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO] systemd: Starting k3s
Result: [INFO] Finding release for channel stable
[INFO] Using v1.21.5+k3s2 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.21.5+k3s2/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.21.5+k3s2/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s.service
[INFO] systemd: Enabling k3s unit
[INFO] systemd: Starting k3s
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.

Saving file to: /home/chip/k8s/kube-vip/kubeconfig

# Test your cluster with:
export KUBECONFIG=/home/chip/k8s/kube-vip/kubeconfig
kubectl config set-context default
kubectl get node -o wide

###################
To join more control plane (server) nodes to this instance, run:

k3sup join --user chip --server-ip 192.168.1.143 --ip --server --k3s-channel stable --k3s-extra-args "--disable traefik --disable servicelb --flannel-backend none --disable-network-policy"

or, to start joining agents run:

k3sup join --user chip --server-ip 192.168.1.143 --ip --k3s-channel stable
```

## Current Behaviour
Currently, k3sup does not print suggested next-step commands.

## Are you a GitHub Sponsor (Yes/No?)

- [ ] Yes
- [x] No

## Possible Solution
Print some templated commands at the end of the block sent to stdout.

## Steps to Reproduce

1. Run `k3sup install` and observe the output to stdout.

## Context

As a new user to `k3sup`, I wanted to deploy a HA cluster to understand the process. As this requires multiple commands against multiple server instances, I had to inspect the help for `k3sup` each time in order to build a command line that would accomplish the use case. While this was not difficult, it occurred to me that perhaps this could be made a little simpler for new (or even existing) users by shortcuting some of that process.

## Your Environment

* What Kubernetes distribution are you using?
K3s 1.21

```
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe34773c74f79527be4afd95bf39", GitTreeState:"clean", BuildDate:"2021-07-15T20:58:09Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.5+k3s2", GitCommit:"724ef700bab896ff252a75e2be996d5f4ff1b842", GitTreeState:"clean", BuildDate:"2021-10-05T19:59:14Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
```

* What OS or type or VM are you using for your cluster? Where is it hosted? (for `k3sup install/join`): vSphere, self-hosted

* Operating System and version (e.g. Linux, Windows, MacOS): Ubuntu 18.04

```
uname -a
Linux k8s-0 4.15.0-162-generic #170-Ubuntu SMP Mon Oct 18 11:38:05 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

cat /etc/os-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
```

## "Be part of the solution"

Subject to approval, are you willing to work on a Pull Request for this issue or feature request?

- [x] Yes
- [] No

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。