当前位置: 首页>>技术教程>>正文


在Ubuntu vm_VT-X/AMD-v中安装Minikube,从而在另一个VM内的VM上启用

, ,

问题描述

我正在尝试在Ubuntu vm(在虚拟框中)中安装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]:

我发现有一个reference,据此,我们无法在虚拟化内部拥有虚拟化。是真的吗我怎样才能解决这个问题?

最佳回答

Virtual Box在嵌套虚拟化中不支持VT-X /AMD-v。在virtualbox.org上看到此打开的ticket/feature request

关于SO讨论this topic,这里还有更多疑问和答案。

可能的解决方案:

  1. 如前所述:在嵌套虚拟化中使用不支持VT-X /AMD-v的其他虚拟机管理程序(例如Xen,KVM或VMware)。

  2. 在主机OS而非VM上安装Minikube。

  3. Tad Guskis answer中所述,使用Docker和”none”驱动程序选项直接运行Minikube。

次佳回答

使用Docker和不需要嵌套虚拟化的”none”驱动程序选项,直接在VM上运行Minikube。

设置无驱动程序选项:

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

按照适用于您的VM OS版本的说明安装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.

第三种回答

尝试在没有嵌套虚拟化的情况下运行minikube(应安装docker):

minikube start --vm-driver=none

从Kubernetes documentation

Minikube also supports a –vm-driver=none option that runs the Kubernetes components on the host and not in a VM. Using this driver requires Docker and a linux environment, but not a hypervisor.

第四种回答

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

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

在VM内核中:

dmesg | egrep 'DMAR|IOMMU'

VirtualBox仅适用于32位嵌套来宾,因此也请检查(它不支持嵌套来宾,但适用于32位):

uname -m

第五种回答

“在主机操作系统上而不是在VM中安装Minikube。”

这不是完全正确的,实际上,您可以使用无驱动程序选项在virtualbox或vmware等之上的Linux VM中安装minikube,它使用localkube直接在VM主机docker中处理kubernetes。

您可以在Linux VM中使用此小脚本在几分钟内启动minikube。

https://github.com/robertluwang/docker-hands-on-guide/blob/master/minikube-none-installation.md

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/10474.html,未经允许,请勿转载。