Open sosukeinu opened 5 months ago
I'm trying to understand wdym by
kubectl [...] has no idea where or how to access krew
kubectl looks at $PATH
to find plugins. So when you type kubectl krew
it will look for kubectl-krew
executable in directories listed in $PATH
.
If you followed the installation instructions on Krew website, the binary is likely at $HOME/.krew/bin/kubectl-krew
which won't work when you run kubectl as a different user. You may want to symlink that path to /usr/local/bin
.
Krew installs any state into $HOME/.krew
of the current user. You can override that with a custom path specified through $KREW_ROOT
environment variable. Maybe you can set $KREW_ROOT
to somewhere like /usr/local/krew
and symlink /usr/local/krew/bin/kubectl-krew
to /usr/local/bin/kubectl-krew
so that multiple users can use the same krew installation+plugins at the same time (granted, $KREW_ROOT
variable must be set in their shells as well).
/kind support
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle rotten
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
I have been trying this as well and thus far am unable to get it to work. I am doing the following to install krew:
(
export KREW_ROOT=/var/opt/krew
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
sudo chmod -R 0755 /var/opt/krew/store/krew/
)
I have the following in /etc/profile.d/krewpath.sh
:
export KREW_ROOT=/var/opt/krew
export PATH=$PATH:/var/opt/krew/bin
When I login, I can see the following...
$ echo $KREW_ROOT
/var/opt/krew
$ echo $PATH
/home/packer/.local/bin:/home/packer/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/var/opt/krew/bin
$ ls -lah /var/opt/krew/bin
total 0
drwxr-xr-x 2 root root 26 Nov 4 17:30 .
drwxr-xr-x 6 root root 59 Nov 4 17:30 ..
lrwxrwxrwx 1 root root 36 Nov 4 17:30 kubectl-krew -> /var/opt/krew/store/krew/v0.4.4/krew
$ ls -lah /var/opt/krew/store/krew/v0.4.4/krew
-rwxr-xr-x 1 root root 12M Nov 4 17:30 /var/opt/krew/store/krew/v0.4.4/krew
Everything there looks good as far as I can tell, yet...
$ kubectl krew
Error: unknown command "krew" for "kubectl"
$ kubectl plugin list
Unable to read directory "/home/packer/.local/bin" from your PATH: open /home/packer/.local/bin: no such file or directory. Skipping...
Unable to read directory "/home/packer/bin" from your PATH: open /home/packer/bin: no such file or directory. Skipping...
: no such file or directory. Skipping...bin\r" from your PATH: open /var/opt/krew/bin
The following compatible plugins are available:
/usr/bin/kubectl-anthos
- error: unable to identify /usr/bin/kubectl-anthos as an executable file: stat /usr/bin/kubectl-anthos: no such file or directory
error: one plugin warning was found
Invoking kubectl-krew directly works fine:
$ /var/opt/krew/bin/kubectl-krew
krew is the kubectl plugin manager.
You can invoke krew through kubectl: "kubectl krew [command]..."
<snip>
Any ideas? 🙏
Following up, it works fine if I copy the binaries to /usr/bin
. Maybe kubectl
doesn't follow symlinks? Had the issue with both kubectl krew
and kubectl hns
(which I installed via krew).
Hello,
I'm trying to use krew with RKE2 which runs by default as the superuser. When I install krew in the userspace, kubectl (which is located at
/var/lib/rancher/rke2/bin/kubectl
and KUBECONFIG is here/etc/rancher/rke2/rke2.yaml
) has no idea where or how to access krew when I typesudo /var/lib/rancher/rke2/bin/kubectl krew update
.I know it is probably pretty simple, but is there a trick to getting krew to work for superuser rather than current user?
Thank you for your time, Jon