minikube
类别: Kubernetes 标签: minikube Docker curl rpm yum目录
安装
安装 kubectl
curl -LO "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
mv ./kubectl /usr/local/bin/kubectl
安装 minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
install minikube-linux-amd64 /usr/local/bin/minikube
启动 Kubernetes 集群
# minikube start --force
😄 Centos 8.1.1911 (amd64) 上的 minikube v1.22.0
❗ minikube skips various validations when --force is supplied; this may lead to unexpected behavior
✨ 自动选择 docker 驱动。其他选项:ssh, none
🛑 The "docker" driver should not be used with root privileges.
💡 If you are running minikube within a VM, consider using --driver=none:
📘 https://minikube.sigs.k8s.io/docs/reference/drivers/none/
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.21.2 preload ...
> preloaded-images-k8s-v11-v1...: 502.14 MiB / 502.14 MiB 100.00% 12.43 Mi
❗ minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.25, but successfully downloaded kicbase/stable:v0.0.25 as a fallback image
🔥 Creating docker container (CPUs=2, Memory=2200MB) ...
❗ This container is having trouble accessing https://k8s.gcr.io
💡 To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
🐳 正在 Docker 20.10.7 中准备 Kubernetes v1.21.2…
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
卸载
# minikube stop
✋ Stopping "minikube" in none ...
🛑 "" stopped.
# minikube delete
🔄 正在使用 kubeadm 卸载 Kubernetes v1.17.3…
🔥 正在删除 none 中的“minikube”…
💀 Removed all traces of the "minikube" cluster.
rm -rf ~/.minikube/
rm -rf ~/.kube/
rm -f /usr/local/bin/minikube
查看集群状态
# minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
附加组件
显示附加组件的当前状态
# minikube addons list
|-----------------------------|----------|--------------|-----------------------|
| ADDON NAME | PROFILE | STATUS | MAINTAINER |
|-----------------------------|----------|--------------|-----------------------|
| ambassador | minikube | disabled | unknown (third-party) |
| auto-pause | minikube | disabled | google |
| csi-hostpath-driver | minikube | disabled | kubernetes |
| dashboard | minikube | disabled | kubernetes |
| default-storageclass | minikube | enabled ✅ | kubernetes |
| efk | minikube | disabled | unknown (third-party) |
| freshpod | minikube | disabled | google |
| gcp-auth | minikube | disabled | google |
| gvisor | minikube | disabled | google |
| helm-tiller | minikube | disabled | unknown (third-party) |
| ingress | minikube | disabled | unknown (third-party) |
| ingress-dns | minikube | disabled | unknown (third-party) |
| istio | minikube | disabled | unknown (third-party) |
| istio-provisioner | minikube | disabled | unknown (third-party) |
| kubevirt | minikube | disabled | unknown (third-party) |
| logviewer | minikube | disabled | google |
| metallb | minikube | disabled | unknown (third-party) |
| metrics-server | minikube | disabled | kubernetes |
| nvidia-driver-installer | minikube | disabled | google |
| nvidia-gpu-device-plugin | minikube | disabled | unknown (third-party) |
| olm | minikube | disabled | unknown (third-party) |
| pod-security-policy | minikube | disabled | unknown (third-party) |
| registry | minikube | disabled | google |
| registry-aliases | minikube | disabled | unknown (third-party) |
| registry-creds | minikube | disabled | unknown (third-party) |
| storage-provisioner | minikube | enabled ✅ | kubernetes |
| storage-provisioner-gluster | minikube | disabled | unknown (third-party) |
| volumesnapshots | minikube | disabled | kubernetes |
|-----------------------------|----------|--------------|-----------------------|
启用附加组件
minikube addons enable dashboard
禁用附加组件
minikube addons disable dashboard
FAQ
❌ Exiting due to DRV_DOCKER_NOT_RUNNING: Found docker, but the docker service isn’t running. Try restarting the docker service.
systemctl start docker
❌ Exiting due to DRV_AS_ROOT: The “docker” driver should not be used with root privileges.
这里当前用户使用的是 root。
解决办法:
minikube start --force --driver=docker
RPM 卸载 minikube
rpm -e minikube
YUM 卸载 Docker
yum remove docker docker-common docker-selinux docker-engine