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

Minikube install in Ubuntu vm_VT-X/AMD-v enabling to VM inside another VM

我打算在 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]:

我找到了一个reference,据此,我们不能在虚拟化中进行虚拟化。是真的吗?我该如何解决这个问题?

检查它是否已正确启用 VM(运行 在 VM 中):

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

在 VM 内核中:

dmesg | egrep 'DMAR|IOMMU'

VirtualBox 仅 works 与 32 位嵌套来宾,因此还要检查(它不 支持 嵌套来宾,但 工作 32 位):

uname -m

我安装了 VM ware 并在 VM 中安装了 Virtualbox。并在外部 VM 中启用 VT-X/AMD-v。它工作正常。

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

这里还有一些关于 SO 讨论 this topic 的问题和答案。

可能的解决方案:

  1. 如前所述:在嵌套虚拟化(如 Xen、KVM 或 VMware)中使用支持 VT-X/AMD-v 的不同管理程序
  2. 在主机 OS 而不是虚拟机中安装 Minikube。
  3. 运行 Minikube 直接使用 Docker 和 "none" 驱动程序选项 ,如 中所述。

"Install Minikube on the host OS and not in a VM."

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

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

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

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

设置none驱动选项:

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

按照您的 VM OS 版本的说明安装 Docker-ce。

最后 运行 minikube 启动:

[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.

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

登录到 esx box 并为您的虚拟机找到 *.vmx 文件。

例如:

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

然后运行 minikube 启动

祝你好运!