- 先下载minikube
https://minikube.sigs.k8s.io/docs/start/
- 前提条件
- 2 CPUs or more
- 2GB of free memory
- 20GB of free disk space
- Internet connection
- Container or virtual machine manager, such as: Docker, QEMU, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation
我本地用的是vmware workstation
需要打开虚拟机并启动docker 服务
- 执行minikube start ,如果直接执行 minikube start --driver=vmware --memory=4096,会报下面的错
C:\Program Files\Kubernetes\Minikube>minikube start --driver=vmware --memory=4096
* Microsoft Windows 10 Home China 10.0.19045.3324 Build 19045.3324 上的 minikube v1.31.2
* 根据用户配置使用 vmware 驱动程序
* 正在下载 VM boot image...
E0904 15:03:48.234735 11476 iso.go:90] Unable to download https://storage.googleapis.com/minikube-builds/iso/16971/minikube-v1.31.0-amd64.iso: getter: &{Ctx:context.Background Src:https://storage.googleapis.com/minikube-builds/iso/16971/minikube-v1.31.0-amd64.iso?checksum=file:https://storage.googleapis.com/minikube-builds/iso/16971/minikube-v1.31.0-amd64.iso.sha256 Dst:C:\Users\xy\.minikube\cache\iso\amd64\minikube-v1.31.0-amd64.iso.download Pwd: Mode:2 Umask:---------- Detectors:[0x47ff5e8 0x47ff5e8 0x47ff5e8 0x47ff5e8 0x47ff5e8 0x47ff5e8 0x47ff5e8] Decompressors:map[bz2:0xc00053b3e0 gz:0xc00053b3e8 tar:0xc00053b370 tar.bz2:0xc00053b380 tar.gz:0xc00053b3b0 tar.xz:0xc00053b3c0 tar.zst:0xc00053b3d0 tbz2:0xc00053b380 tgz:0xc00053b3b0 txz:0xc00053b3c0 tzst:0xc00053b3d0 xz:0xc00053b3f0 zip:0xc00053b400 zst:0xc00053b3f8] Getters:map[file:0xc000e50010 http:0xc0004c2550 https:0xc0004c25a0] Dir:false ProgressListener:0x4793370 Insecure:false DisableSymlinks:false Options:[0x1b11520]}: invalid checksum: Error downloading checksum file: Get "https://storage.googleapis.com/minikube-builds/iso/16971/minikube-v1.31.0-amd64.iso.sha256": read tcp 192.168.6.112:10305->142.251.42.240:443: wsarecv: An existing connection was forcibly closed by the remote host.
* 正在下载 VM boot image...
> minikube-v1.31.0-amd64.iso....: 65 B / 65 B [---------] 100.00% ? p/s 0s
> minikube-v1.31.0-amd64.iso: 289.20 MiB / 289.20 MiB 100.00% 9.33 MiB p/
* 正在集群 minikube 中启动控制平面节点 minikube
* 正在创建 vmware VM(CPUs=2,内存=4096MB,磁盘=20000MB)...
! The image 'gcr.io/k8s-minikube/storage-provisioner:v5' was not found; unable to add it to cache.
! The image 'registry.k8s.io/kube-controller-manager:v1.27.4' was not found; unable to add it to cache.
! The image 'registry.k8s.io/coredns/coredns:v1.10.1' was not found; unable to add it to cache.
! The image 'registry.k8s.io/kube-proxy:v1.27.4' was not found; unable to add it to cache.
! The image 'registry.k8s.io/pause:3.9' was not found; unable to add it to cache.
! The image 'registry.k8s.io/kube-apiserver:v1.27.4' was not found; unable to add it to cache.
! The image 'registry.k8s.io/etcd:3.5.7-0' was not found; unable to add it to cache.
! The image 'registry.k8s.io/kube-scheduler:v1.27.4' was not found; unable to add it to cache.
* 正在 Docker 24.0.4 中准备 Kubernetes v1.27.4…
X Unable to load cached images: loading cached images: CreateFile C:\Users\xy\.minikube\cache\images\amd64\registry.k8s.io\pause_3.9: The system cannot find the file specified.
> 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: 46.98 MiB / 46.98 MiB [--------------] 100.00% 2.82 MiB p/s 17s
> kubeadm: 45.93 MiB / 45.93 MiB [--------------] 100.00% 1.11 MiB p/s 42s
> kubelet: 101.25 MiB / 101.25 MiB [----------] 100.00% 1.11 MiB p/s 1m31s
所以替换国内的镜像就可以了
minikube start --driver=vmware --memory=4096 --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
执行成功会看到下面的界面
C:\Program Files\Kubernetes\Minikube>minikube start --driver=vmware --memory=4096 --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
* Microsoft Windows 10 Home China 10.0.19045.3324 Build 19045.3324 上的 minikube v1.31.2
* 根据用户配置使用 vmware 驱动程序
* 正在使用镜像存储库 registry.cn-hangzhou.aliyuncs.com/google_containers
* 正在集群 minikube 中启动控制平面节点 minikube
* 正在创建 vmware VM(CPUs=2,内存=4096MB,磁盘=20000MB)...
* 正在 Docker 24.0.4 中准备 Kubernetes v1.27.4…
- 正在生成证书和密钥...
- 正在启动控制平面...
- 配置 RBAC 规则 ...
* 配置 bridge CNI (Container Networking Interface) ...
* 正在验证 Kubernetes 组件...
- 正在使用镜像 registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v5
* 启用插件: default-storageclass, storage-provisioner
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* 完成!kubectl 现在已配置,默认使用"minikube"集群和"default"命名空间
- 简单操作
minikube kubectl -- get po -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-65dcc469f7-qnqjf 1/1 Running 0 4m18s
kube-system etcd-minikube 1/1 Running 0 4m31s
kube-system kube-apiserver-minikube 1/1 Running 0 4m31s
kube-system kube-controller-manager-minikube 1/1 Running 0 4m31s
kube-system kube-proxy-tr44s 1/1 Running 0 4m18s
kube-system kube-scheduler-minikube 1/1 Running 0 4m31s
kube-system storage-provisioner 1/1 Running 0 4m29s
网友评论