minikube User Guide

minikube 用户指南

单机版 k8s 环境,依赖 docker 等容器引擎,需要普通用户启动运行。root 可以通过设置环境变量操作启动后的 minikube。

安装

Linux 下载二进制文件

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
mv minikube-linux-amd64 /usr/bin/minikube
chmod +x /usr/bin/minikube

Windows

choco install minikube

常用命令

命令 作用
export KUBECONFIG=/home/USER/.kube/config  操作 USER 启动的 minikube
minikube config 查看可设置项目
minikube config set memory 6114 设置可用内存
minikube config set cpus 2
minikube config set kubernetes-version v1.23.5 指定版本启动
minikube start --memory 8192 --cpus 2 指定硬件启动
minikube start --image-mirror-country='cn' --registry-mirror=https://注册表加速服务 指定中国镜像、加速服务启动
minikube ssh 进入 minikube 终端
minikube stop 关闭 minikube
minikube dashboard --url=false 启动管理面板
minikube addons list 查看可用扩展
minikube addons enable ingress
minikube addons enable ingress-dns
kubectl port-forward POD_NAME HOST_PORT:POD_PORT 映射主机端口到 pod

Troubleshooting

启动超时

minikube 启动时需要下载 kubectl、kubeadm、kubelet 三个工具,Windows 下载失败时,可以设置代理解决。

❌  Exiting due to INET_DOWNLOAD_BLOCKED: updating control plane: downloading binaries: downloading kubelet: download failed:
set HTTP_PROXY=http://hostname:port
set HTTPS_PROXY=https://hostname:port
set NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.59.0/24,192.168.39.0/24
> minikube start --image-mirror-country='cn' --registry-mirror=https://.mirror.aliyuncs.com --cpus 4 --memory 4608
😄  minikube v1.25.2 on Microsoft Windows 10 Pro 10.0.19044 Build 19044
    ▪ KUBECONFIG=C:\Users\Administrator\.kube\config
    ▪ MINIKUBE_HOME=C:\Users\Administrator\.minikube
✨  Using the docker driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
🤷  docker "minikube" container is missing, will recreate.
🔥  Creating docker container (CPUs=4, Memory=4608MB) ...
❗  Listening to 0.0.0.0 on external docker host 192.168.3.66. Please be advised
🐳  Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
    ▪ kubelet.housekeeping-interval=5m
    > kubelet.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubectl: 44.43 MiB / 44.43 MiB [-----------] 100.00% 503.16 KiB p/s 1m31s
    > kubeadm: 43.12 MiB / 43.12 MiB [------------] 100.00% 342.58 KiB p/s 2m9s
    > kubelet: 106.26 MiB / 118.75 MiB [-------->] 89.48% 171.44 KiB p/s 10m35s
    > kubelet: 118.75 MiB / 118.75 MiB [-------------] 100.00% 4.18 MiB p/s 29s
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
Author: njun
njun's picture
Updated: 2022/05/09