安装Minikube

半兽人 发表于: 2019-12-12   最后更新时间: 2020-05-03  

本章将介绍如何安装Minikube,可在个人计算机上的虚拟机中运行单节点Kubernetes集群。

验证是否支持虚拟化

Linux

要检查Linux是否支持虚拟化,请运行以下命令并验证输出是否为非空:

grep -E --color 'vmx|svm' /proc/cpuinfo

macOS

要检查macOS是否支持虚拟化,请在终端上运行以下命令。

sysctl -a | grep -E --color 'machdep.cpu.features|VMX'

如果您在输出中看到VMX(应为彩色),则表明您的计算机已启用VT-x功能。

Windows

要检查Windows 8及更高版本是否支持虚拟化,请在Windows终端或命令提示符下运行以下命令。

systeminfo

如果看到以下输出,则说明Windows支持虚拟化。

Hyper-V Requirements:     VM Monitor Mode Extensions: Yes
                          Virtualization Enabled In Firmware: Yes
                          Second Level Address Translation: Yes
                          Data Execution Prevention Available: Yes

如果看到以下输出,则说明您的系统已经安装了系统管理程序,可以跳过下一步。

Hyper-V Requirements:     A hypervisor has been detected. Features required for Hyper-V will not be displayed.

Linux安装minikube

安装 Kubectl

确保您已安装kubectl。您可以根据“安装和设置kubectl”中的说明安装kubectl。

安装Hypervisor

如果尚未安装hypervisor,请立即安装以下之一:

KVM, 也事业 QEMU

VirtualBox

注意:Minikube也支持--vm-driver=none选项,该选项在主机而不是VM中运行Kubernetes组件。使用此驱动程序需要Docker和Linux环境,但不需要hypervisor。 当使用none驱动程序时,建议使用apt安装Docker。docker的快照安装不兼容minikube。

使用软件包安装Minikube

There are experimental packages for Minikube available; you can find Linux (AMD64) packages from Minikube’s releases page on GitHub.

Use your Linux’s distribution’s package tool to install a suitable package.

Install Minikube via direct download

If you’re not installing via a package, you can download a stand-alone binary and use that.

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube

Here’s an easy way to add the Minikube executable to your path:

sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/
Install Minikube using Homebrew

As yet another alternative, you can install Minikube using Linux Homebrew:

brew install minikube

Confirm Installation

To confirm successful installation of both a hypervisor and Minikube, you can run the following command to start up a local Kubernetes cluster:

Note: For setting the --vm-driver with minikube start, enter the name of the hypervisor you installed in lowercase letters where is mentioned below. A full list of --vm-driver values is available in specifying the VM driver documentation.

minikube start --vm-driver=<driver_name>

Once minikube start finishes, run the command below to check the status of the cluster:

minikube status

If your cluster is running, the output from minikube status should be similar to:

host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

After you have confirmed whether Minikube is working with your chosen hypervisor, you can continue to use Minikube or you can stop your cluster. To stop your cluster, run:

minikube stop

Clean up local state

If you have previously installed Minikube, and run:

minikube start

and minikube start returned an error:

machine does not exist

then you need to clear minikube’s local state:

minikube delete


您需要解锁本帖隐藏内容请: 点击这里
本帖隐藏的内容




上一条: 使用Minikube安装Kubernetes
下一条: 使用部署工具安装 Kubernetes(k8s)