Minikube

Minikube是一种工具,可以在本地轻松运行Kubernetes。(Minikube is a tool that makes it easy to run Kubernetes locally.)

Github stars Tracking Chart

Minikube

什么是Minikube?

Minikube是一款让本地运行Kubernetes变得简单的工具。 Minikube在笔记本电脑的虚拟机内部运行一个单节点Kubernetes集群,以便用户试用Kubernetes或每天进行开发。

安装

MACOS

Homebrew是macOS的包管理器,可用于安装Minikube。 安装Homebrew后,在终端提示符下运行以下命令:

 brew cask install minikube

这也安装了kubernets-cli包。可以使用以下方法验证这一点

kubectl version

如果没有安装,就使用它来安装

brew install kubernetes-cli

Linux

 curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && sudo install minikube-linux-amd64 /usr/local/bin/minikube

Windows

需要启用Hyper-V。 对于Windows 10,这只能在这些版本上运行:

  • Windows 10 Enterprise
  • Windows 10 Professional
  • Windows 10 Education

使用Chocolatey 安装(推荐):

这些命令必须以管理员身份运行。 要执行此操作,请在开始菜单中键入“cmd”,右键单击并选择“以管理员身份运行”,打开Windows命令行。

choco install minikube
choco install kubernetes-cli

安装完成后,关闭当前命令行并重新启动。 Minikube已自动添加到您的路径中。

要启动minikube群集,请确保您还具有管理员权限。

minikube start

您可能必须指定vm驱动程序。

minikube start --vm-driver hyperv

手动安装

下载 minikube-windows-amd64.exe 文件,将其重命名到 minikube.exe 并将其添加到您的路径。

没有VM支持的Linux持续集成

使用kubectl安装的示例:

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo cp minikube /usr/local/bin/ && rm minikube
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo cp kubectl /usr/local/bin/ && rm kubectl

export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
export MINIKUBE_HOME=$HOME
export CHANGE_MINIKUBE_NONE_USER=true
mkdir -p $HOME/.kube
mkdir -p $HOME/.minikube
touch $HOME/.kube/config

export KUBECONFIG=$HOME/.kube/config
sudo -E minikube start --vm-driver=none

# this for loop waits until kubectl can access the api server that Minikube has created
for i in {1..150}; do # timeout for 5 minutes
   kubectl get po &> /dev/null
   if [ $? -ne 1 ]; then
      break
  fi
  sleep 2
done

# kubectl commands are now able to interact with Minikube cluster

其他安装方法

Minikube版本管理

asdf 工具为广泛的语言和工具提供版本管理。在macOS上,通过Homebrew可以访问 asdf ,并且可以使用 brew install asdf 进行安装。然后,Minikube插件本身可以安装 asdf plugin-add minikube 。可以使用 asdf install minikube< version> 安装特定版本的Minikube。该工具允许您在项目中使用 .tool-versions 文件切换项目的版本。还有一个asdf插件用于kubectl。

我们还在发布页面上发布了Debian软件包和Windows安装程序。如果您维护Minikube软件包,请随时在此处添加。

要求

快速启动

这是Minikube使用的简要演示。

如果你愿意t更改VM驱动程序将相应的 --vm-driver=xxx 标志添加到 minikube start 。 Minikube支持 以下驱动程序:

$ minikube start
Starting local Kubernetes v1.7.5 cluster...
Starting VM...
SSH-ing files into VM...
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster.

$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080
deployment "hello-minikube" created
$ kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed

# We have now launched an echoserver pod but we have to wait until the pod is up before curling/accessing it
# via the exposed service.
# To check whether the pod is up and running we can use the following:
$ kubectl get pod
NAME                              READY     STATUS              RESTARTS   AGE
hello-minikube-3383150820-vctvh   1/1       ContainerCreating   0          3s
# We can see that the pod is still being created from the ContainerCreating status
$ kubectl get pod
NAME                              READY     STATUS    RESTARTS   AGE
hello-minikube-3383150820-vctvh   1/1       Running   0          13s
# We can see that the pod is now Running and we will now be able to curl it:
$ curl $(minikube service hello-minikube --url)
CLIENT VALUES:
client_address=192.168.99.1
command=GET
real path=/
...
$ kubectl delete service hello-minikube
service "hello-minikube" deleted
$ kubectl delete deployment hello-minikube
deployment "hello-minikube" deleted
$ minikube stop
Stopping local Kubernetes cluster...
Machine stopped.

与你的群集交互

kubectl

minikube start 命令创建一个“ kubectl context”,称为“minikube”。 此上下文包含与您的Minikube群集进行通信的配置。

Minikube将此上下文自动设置为默认值,但如果您以后需要切换回默认值,请运行:

kubectl config use-context minikube,

或者像这样在每个命令上传递上下文:kubectl get pods --context=minikube

控制台

要访问 Kubernetes Dashboard ,请在启动Minikube后在shell中运行以下命令以获取地址:

minikube dashboard

服务

要访问通过节点端口公开的服务,请在启动Minikube后在shell中运行此命令以获取地址:

minikube service [-n NAMESPACE] [--url] NAME

设计

Minikube使用 libmachine 来配置VM(虚拟机),以及 localkube 来配置集群。

有关Minikube的更多信息,请参阅提案

其他链接

社区

Overview

Name With Ownerkubernetes/minikube
Primary LanguageGo
Program languageGo (Language Count: 15)
PlatformLinux, Mac, Windows
License:Apache License 2.0
Release Count147
Last Release Namev1.33.0 (Posted on 2024-04-19 14:26:40)
First Release Namev0.1.0 (Posted on 2016-05-30 09:21:46)
Created At2016-04-15 22:38:35
Pushed At2024-05-06 15:46:46
Last Commit At2024-05-01 19:32:48
Stargazers Count28.4k
Watchers Count483
Fork Count4.8k
Commits Count24.1k
Has Issues Enabled
Issues Count9348
Issue Open Count778
Pull Requests Count7611
Pull Requests Open Count68
Pull Requests Close Count1740
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

minikube

BuildStatus Widget
GoReport Widget

minikube implements a local Kubernetes cluster on macOS, Linux, and Windows. minikube's primary goals are to be the best tool for local Kubernetes application development and to support all Kubernetes features that fit.

Features

minikube runs the latest stable release of Kubernetes, with support for standard Kubernetes features like:

As well as developer-friendly features:

For more information, see the official minikube website

Installation

See the Getting Started Guide

:mega: Please fill out our fast 5-question survey so that we can learn how & why you use minikube, and what improvements we should make. Thank you! :dancers:

Documentation

See https://minikube.sigs.k8s.io/docs/

More Examples

See our examples page

Community

minikube is a Kubernetes #sig-cluster-lifecycle project.

To the top