在Ubuntu虚拟机中安装Minikube_VM内部启用VT-X/AMD-v功能

29

我正在尝试在Ubuntu虚拟机(在虚拟盒子中)安装Minikube。我已经为虚拟机启用了VT-X/AMD-v。但是我遇到了以下错误。

# minikube start
Starting local Kubernetes cluster...
E0217 15:00:35.395801    3869 start.go:107] Error starting host: Error creating host: Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory".

 Retrying.
E0217 15:00:35.396019    3869 start.go:113] Error starting host:  Error creating host: Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory"
================================================================================
An error has occurred. Would you like to opt in to sending anonymized crash
information to minikube to help prevent future errors?
To opt out of these messages, run the command:
    minikube config set WantReportErrorPrompt false
================================================================================
Please enter your response [Y/n]:

我找到了一个参考资料,根据它的说法,我们不能在虚拟化中再进行虚拟化。这是真的吗?我该怎么解决这个问题呢?


为什么不在您的主机上运行minikube呢?Windows、macOS和Linux都有编译好的二进制文件。 - Matt Rickard
在我把它部署到Ubuntu远程服务器之前,我需要在我的虚拟机中进行测试。 - Lakmal Vithanage
7个回答

25

Virtual Box不支持嵌套虚拟化中的VT-X/AMD-v。请参阅virtualbox.org上这个开放的ticket/feature request

在SO上还有一些更多的问题和答案讨论主题

可能的解决方案:

  1. 如前所述:使用支持VT-X/AMD-v嵌套虚拟化的不同虚拟机监控程序(如Xen,KVM或VMware)。
  2. 在主机操作系统上安装Minikube而不是在虚拟机中安装。
  3. 直接使用Docker和“none”驱动器选项运行Minikube,如Tad Guskis答案中所述。Tad Guskis answer

1
我可以在 AWS Ubuntu EC2 实例上运行 minikube 吗?ubuntu@ip-172-31-22-20:~$ uname -a Linux ip-172-31-22-20 3.13.0-137-generic #186-Ubuntu SMP Mon Dec 4 19:09:19 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux - Ashish Karpe
请提出单独的问题或在您的情况下直接参考AWS支持。 - Phonolog
1
如果您喜欢使用VirtualBox,您仍然可以通过在VirtualBox中安装Docker并运行 minikube start --vm-driver=none 来实现此目的,就像 @k13i 解决方案所述。 - Ardee Aram
对于新来的人,请注意,这个答案已经不再有效,因为该问题已经关闭,并且在Virtual Box 6.1.0中实现了嵌套虚拟化。 - undefined

24

使用Docker和“none”驱动选项直接在虚拟机上运行Minikube,无需嵌套虚拟化。

设置 none 驱动选项:

[root@minikube ~]# minikube config set vm-driver none

按照您的虚拟机操作系统版本的说明安装Docker-ce。

最后运行minikube start:

[root@minikube ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@minikube ~]# systemctl start docker
[root@minikube ~]# minikube start
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Downloading kubeadm v1.10.0
Downloading kubelet v1.10.0
Finished Downloading kubelet v1.10.0
Finished Downloading kubeadm v1.10.0
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
===================
WARNING: IT IS RECOMMENDED NOT TO RUN THE NONE DRIVER ON PERSONAL WORKSTATIONS
        The 'none' driver will run an insecure kubernetes apiserver as root that may leave the host vulnerable to CSRF attacks

When using the none driver, the kubectl config and credentials generated will be root owned and will appear in the root home directory.
You will need to move the files to the appropriate location and then set the correct permissions.  An example of this is below:

        sudo mv /root/.kube $HOME/.kube # this will write over any previous configuration
        sudo chown -R $USER $HOME/.kube
        sudo chgrp -R $USER $HOME/.kube

        sudo mv /root/.minikube $HOME/.minikube # this will write over any previous configuration
        sudo chown -R $USER $HOME/.minikube
        sudo chgrp -R $USER $HOME/.minikube

This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true
Loading cached images from config file.

7

如果您已安装Docker,请尝试在不使用嵌套虚拟化的情况下运行Minikube:

minikube start --vm-driver=none

从 Kubernetes 文档中得知:
Minikube还支持--vm-driver=none选项,它在主机上运行Kubernetes组件而不是在虚拟机中运行。使用此驱动程序需要Docker和Linux环境,但不需要虚拟化技术。

4

3

检查虚拟机中是否已正确启用(在虚拟机内运行):

egrep -i '^flags.*(svm|vmx)' /proc/cpuinfo

在虚拟机内核中:

dmesg | egrep 'DMAR|IOMMU'

VirtualBox只支持32位的嵌套虚拟机,因此还需要检查(它不支持嵌套虚拟机,但支持32位):

uname -m

[49.563077] vboxpci:找不到IOMMU(未注册) - Lakmal Vithanage
1
你的虚拟机是32位还是64位?VirtualBox不支持64位的嵌套虚拟机。 - Janos Lenart
1
我安装了VMware并在其中安装了Virtualbox。并在外部VM中启用了VT-X/AMD-v。它运行良好。 - Lakmal Vithanage

1

我安装了VMware并在其中安装了Virtualbox,同时在外部VM中启用了VT-X/AMD-v。它运行得很好。


0

在VirtualBox的.vmx文件中设置以下属性。

登录到ESX Box并找到您的虚拟机的*.vmx文件。

e.g.:

echo 'vhv.enable = "TRUE"' >> /vmfs/volumes/54183927-04f91918-a72a-6805ca147c55/ubun204_mk/ubun204_mk.vmx 

然后运行 minikube start

祝你好运!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接