Closed sschaeffner closed 8 months ago
Hi @sschaeffner , thanks for your PR
This behavior seems a bit weird because the k3s
should install everything into /usr/bin/local
by default (https://get.k3s.io/), where the kubectl
should go too (it is a link to the k3s
binary)
# - INSTALL_K3S_BIN_DIR
# Directory to install k3s binary, links, and uninstall script to, or use
# /usr/local/bin as the default
Did you changed this variable ?
Hi @xunleii
sorry for not mentioning this in the description: yes, I have set INSTALL_K3S_BIN_DIR
to /opt/bin
as /usr/bin/local
is read-only on Flatcar Linux.
I think the k3s installation adds the INSTALL_K3S_BIN_DIR
to PATH
if it's not yet in PATH
(I haven't checked the install script in depth).
After reading the installation script, it does not modify the PATH in the profile file (or elsewhere).
What I can suggest is to add INSTALL_K3S_BIN_DIR: "/usr/local/bin"
as a default value to k3s_install_env_vars
and use it in the definition of kubectl_cmd
like this:
kubectl_cmd = var.use_sudo ? "sudo ${var.k3s_install_env_vars["INSTALL_K3S_BIN_DIR"]}/kubectl" : "${var.k3s_install_env_vars["INSTALL_K3S_BIN_DIR"]}/kubectl"
With this, we will always call the right kubectl
everywhere.
This pull request has been automatically marked as stale because it has not had recent activity. If the pull request still needs attention, please leave a comment and it will be reopened.
On flatcar Linux, the kubectl binary is installed to /opt/bin/kubectl, which apparently is not in PATH at time of script start.
Previously, it produced: module.k3s.null_resource.servers_install["machine"] (remote-exec): /tmp/terraform_931163766.sh: line 3: kubectl: command not found