alexellis/k3sup

[Feature request] Configurable node token path for custom --data-dir installations of K3s

fhriley opened this issue · 5 comments

I installed the server as follows:

k3sup install --ip <SERVER_IP> --sudo false --k3s-extra-args "--data-dir /mnt/ssd/k3s"

I then attempted to join a node:

k3sup join --ip <IP> --server-ip <SERVER_IP> --sudo false --k3s-extra-args "--data-dir /mnt/ssd/k3s"
Running: k3sup join
Server IP: 192.168.1.224
cat: /var/lib/rancher/k3s/server/node-token: No such file or directory
Error: unable to get join-token from server: Process exited with status 1

So then I did this:

export K3S_TOKEN="..."

and tried again. It still failed. I looked at the code, and I see that the token path is hardcoded with no way to override it.

Expected Behaviour

Joining a node succeeds.

Current Behaviour

Joining a node fails.

Are you a GitHub Sponsor (Yes/No?)

  • Yes
  • No

Possible Solution

Add a command line option to set the data dir path.

Steps to Reproduce

  1. k3sup install --ip <SERVER_IP> --sudo false --k3s-extra-args "--data-dir /mnt/ssd/k3s"
  2. k3sup join --ip <IP> --server-ip <SERVER_IP> --sudo false --k3s-extra-args "--data-dir /mnt/ssd/k3s"

Context

Your Environment

  • What Kubernetes distribution are you using?
kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.3", GitCommit:"816c97ab8cff8a1c72eccca1026f7820e93e0d25", GitTreeState:"clean", BuildDate:"2022-01-25T21:17:57Z", GoVersion:"go1.17.6", Compiler:"gc", Platform:"darwin/arm64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.6+k3s1", GitCommit:"3228d9cb9a4727d48f60de4f1ab472f7c50df904", GitTreeState:"clean", BuildDate:"2022-01-25T01:14:20Z", GoVersion:"go1.16.10", Compiler:"gc", Platform:"linux/arm64"}
  • What OS or type or VM are you using for your cluster? Where is it hosted? (for k3sup install/join):
root@k3s-server:/mnt/ssd/k3s# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
  • Operating System and version (e.g. Linux, Windows, MacOS):
uname -a
Darwin macbook.gearheadsw.com 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

"Be part of the solution"

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

  • Yes
  • No

I am having the same issue. Is it so unusual not to use the default data path? That sounds like a easy win what @fhriley is suggesting.

Actually the better way would be to just provide the --token option like it is specified in the install command by default - otherwise fall back to try to guess the token from a local k3s server.

token, err := command.Flags().GetString("token")

Actually the better way would be to just provide the --token option like it is specified in the install command by default - otherwise fall back to try to guess the token from a local k3s server.

token, err := command.Flags().GetString("token")

The token is not the problem. Not being able to change the data path is the problem.

If I understand this correctly, this issue only affects people who are using a different --data-dir parameter to install K3s?

I don't receive any funding or support for K3sup, so I'm seeing three differently people asking me to do work for them and to improve K3sup, for their use-case (one that I don't have)

None of you are sponsoring me on GitHub. If you'd like to gain some influence, maybe you should consider changing that? https://github.com/sponsors/alexellis

@alexellis made a one time donation as a small thank you