什么是 minikube ?
它是本地的 kubernetes ,专注于学习和开发的 kubernetes 本地虚拟环境。
| 名称 | 地址 |
|---|---|
| 官方网址 | https://minikube.sigs.k8s.io/ |
| 其它平台和架构下安装程序 | https://minikube.sigs.k8s.io/docs/start/ |
安装 minikube
注意:在使用 minikube 需要提前安装好 docker 和 kubernetes
在 linux 下安装 minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
在 macos 下安装 minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64
sudo install minikube-darwin-amd64 /usr/local/bin/minikube
在 windows 下安装 minikube
- 在管理员模式下打开
PowerShell执行下面的命令
New-Item -Path 'c:\' -Name 'minikube' -ItemType Directory -Force
Invoke-WebRequest -OutFile 'c:\minikube\minikube.exe' -Uri 'https://github.com/kubernetes/minikube/releases/latest/download/minikube-windows-amd64.exe' -UseBasicParsing
- 在管理员模式下打开
PowerShell添加环境变量
$oldPath = [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine)
if ($oldPath.Split(';') -inotcontains 'C:\minikube'){ `
[Environment]::SetEnvironmentVariable('Path', $('{0};C:\minikube' -f $oldPath), [EnvironmentVariableTarget]::Machine) `
}
验证是否安装成功
$ minikube version
minikube version: v1.25.2
commit: 362d5fdc0a3dbee389b3d3f1034e8023e72bd3a7
基本操作
- 启动集群
minikube start
- 国内镜像启动集群
minikube start --image-mirror-country=cn
- 停止集群
minikube stop
- 清空集群
minikube delete --all
- 在浏览器中打开仪表板
Kubernetes Dashboard
minikube dashboard
获取帮助
$ minikube --help
minikube provisions and manages local Kubernetes clusters optimized for development workflows.
Basic Commands:
start Starts a local Kubernetes cluster
status Gets the status of a local Kubernetes cluster
stop Stops a running local Kubernetes cluster
delete Deletes a local Kubernetes cluster
dashboard 访问在 minikube 集群中运行的 kubernetes dashboard
pause pause Kubernetes
unpause 恢复 Kubernetes
Images Commands:
docker-env 配置环境以使用 minikube's Docker daemon
podman-env 配置环境以使用 minikube's Podman service
cache Add, delete, or push a local image into minikube
image Manage images
Configuration and Management Commands:
addons Enable or disable a minikube addon
config Modify persistent configuration values
profile Get or list the current profiles (clusters)
update-context Update kubeconfig in case of an IP or port change
Networking and Connectivity Commands:
service Returns a URL to connect to a service
tunnel 连接到 LoadBalancer 服务
Advanced Commands:
mount 将指定的目录挂载到 minikube
ssh Log into the minikube environment (for debugging)
kubectl Run a kubectl binary matching the cluster version
node Add, remove, or list additional nodes
cp Copy the specified file into minikube
Troubleshooting Commands:
ssh-key Retrieve the ssh identity key path of the specified node
ssh-host Retrieve the ssh host key of the specified node
ip Retrieves the IP address of the specified node
logs Returns logs to debug a local Kubernetes cluster
update-check 打印当前和最新版本版本
version 打印 minikube 版本
options 显示全局命令行选项列表 (应用于所有命令)。
Other Commands:
completion Generate command completion for a shell
Use "minikube <command> --help" for more information about a given command.