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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

虚拟机里找不到kubctl命令:-bash: kubectl: command not found #93

Open
WinnerSong opened this issue May 20, 2020 · 7 comments
Open
Labels
kind/need-details Need more information

Comments

@WinnerSong
Copy link

安装完成后,3个节点状态正常,使用命令 vagrant ssh node1 进入虚拟机,执行命令 sudo -i 报 kubectl 命令不存在 -bash: kubectl: command not found,这是哪个环节出问题了

@rootsongjc
Copy link
Owner

你先进入虚拟机中确认下 Kubernetes 的安装包是否还在?

@rootsongjc rootsongjc added the kind/need-details Need more information label May 21, 2020
@sologgfun
Copy link

sologgfun commented Jun 28, 2020

这个问题我也碰到了,自己鼓捣一下解决了,记录一下吧
现象如下:
【1】虚拟机里找不到kubctl命令
【2】宿主机里的kubeltes get nodes也是被refused
原因如下:
【1】第一次vagrant up执行的时候目录下面没有正确的kubernetes安装包
【2】之后使用了正确的kebernetes安装包
【3】通过vagrant halt和vagrant up重启了虚拟机
【4】虚拟机下有正确的安装包
【5】但是由于第一次创建虚拟机时没有正确的安装包,所以导致虚拟机本身的环境已经有问题了,通过halt和up没有办法修复
(猜测应该是之后有的步骤被跳过了)
解决办法:
【1】清理虚拟机

    vagrant destroy
    rm -rf .vagrant

【2】重新初始化虚拟机

 vagrant up

@rootsongjc
Copy link
Owner

最好是提前将 kubernetes 安装包下载到本地,然后运行脚本。如果实在没有安装上 kubectl 可以进入虚拟机中手动安装下。

@zuoliang0
Copy link

最好是提前将 kubernetes 安装包下载到本地,然后运行脚本。如果实在没有安装上 kubectl 可以进入虚拟机中手动安装下。

 请问能完善一下这方面的文档吗?现在国内基本上都没办法完成你项目都测试,怀疑就是这个问题

@rootsongjc
Copy link
Owner

目前我本地没有测试环境,在个人 PC 上运行 3 个虚拟机的开销实在太大,我暂时没有办法来复现上面的错误,谁有环境可以试一下。

@gh0sthx
Copy link

gh0sthx commented May 21, 2021

大致原因是网络问题,

node1: --2021-05-21 09:05:39--  https://storage.googleapis.com/kubernetes-release/release/v1.15.0/kubernetes-server-linux-amd64.tar.gz
node1: tar (child): /vagrant/kubernetes-server-linux-amd64.tar.gz: Cannot open: No such file or directory
...
 node1: Configure Kubectl to autocomplete
    node1: /tmp/vagrant-shell: line 221: kubectl: command not found

@gh0sthx
Copy link

gh0sthx commented May 21, 2021

注意:如果您是第一次运行该部署程序,那么可以直接执行下面的命令,它将自动帮你下载 Kubernetes 安装包,下一次你就不需要自己下载了,另外您也可以在这里找到Kubernetes的发行版下载地址,下载 Kubernetes发行版后重命名为kubernetes-server-linux-amd64.tar.gz,并移动到该项目的根目录下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/need-details Need more information
Projects
None yet
Development

No branches or pull requests

5 participants