Windows安装Minikube体验Kubernetes(k8s)集群

Kubernetes(k8s) 用于协调高度可用的计算机集群,Minikube用于学习和测试使用,可以在一台节点上很方便的部署 Kubernetes(k8s) 集群环境。

一、环境

Win10:直接在win10使用 Minikube,没有使用虚拟机。Windows必须支持虚拟化,可以执行“systeminfo”命令来确认。

二、安装

下载 Minikube,下载地址。Minikube 是绿色软件,下载后放到 C:\Windows\目录下即可。
下载 kubectl,下载地址。kubectl 是管理 Kubernetes 集群的命令行工具,也是绿色软件,下载后放到 C:\Windows\目录下即可。
安装 Docker ,官网下载安装包,一路下一步安装即可。安装之后,需要打开一次来确认安装是否成功。

三、运行

minikube start --disk-size="10g"  --image-mirror-country="cn"  --image-repository="registry.cn-hangzhou.aliyuncs.com/google_containers"

如果报下面的错误,请将 172.217.160.112 storage.googleapis.com 加入 C:\Windows\System32\drivers\etc\hosts 文件的末尾一行。

X Exiting due to K8S_INSTALL_FAILED: updating control plane: downloading binaries: downloading kubeadm: download failed: https://storage.googleapis.com/kubernetes-release/release/v1.23.3/bin/linux/amd64/kubeadm?checksum=file:https://storage.googleapis.com/kubernetes-release/release/v1.23.3/bin/linux/amd64/kubeadm.sha256: getter: &{Ctx:context.Background Src:https://storage.googleapis.com/kubernetes-release/release/v1.23.3/bin/linux/amd64/kubeadm?checksum=file:https://storage.googleapis.com/kubernetes-release/release/v1.23.3/bin/linux/amd64/kubeadm.sha256 Dst:C:\Users\Administrator.minikube\cache\linux\amd64\v1.23.3/kubeadm.download Pwd: Mode:2 Umask:---------- Detectors:[0x3c18fc0 0x3c18fc0 0x3c18fc0 0x3c18fc0 0x3c18fc0 0x3c18fc0 0x3c18fc0] Decompressors:map[bz2:0x3c18fc0 gz:0x3c18fc0 tar:0x3c18fc0 tar.bz2:0x3c18fc0 tar.gz:0x3c18fc0 tar.xz:0x3c18fc0 tar.zst:0x3c18fc0 tbz2:0x3c18fc0 tgz:0x3c18fc0 txz:0x3c18fc0 tzst:0x3c18fc0 xz:0x3c18fc0 zip:0x3c18fc0 zst:0x3c18fc0] Getters:map[file:0xc00095b020 http:0xc000c63a60 https:0xc000c63a80] Dir:false ProgressListener:0x3bb1040 Insecure:false Options:[0x1e14000]}: invalid checksum: Error downloading checksum file: Get "https://storage.googleapis.com/kubernetes-release/release/v1.23.3/bin/linux/amd64/kubeadm.sha256": proxyconnect tcp: EOF

出现下面的 Done 提示,表示安装成功。

* Microsoft Windows 10 Pro 10.0.19043 Build 19043 上的 minikube v1.25.2
* 根据现有的配置文件使用 docker 驱动程序
! You cannot change the disk size for an existing minikube cluster. Please first delete the cluster.
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Updating the running docker "minikube" container ...
! This container is having trouble accessing https://registry.cn-hangzhou.aliyuncs.com/google_containers
* To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
* 正在 Docker 20.10.12 中准备 Kubernetes v1.23.3…
  - kubelet.housekeeping-interval=5m
    > kubelet.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubectl: 44.43 MiB / 44.43 MiB [------------] 100.00% 107.26 KiB p/s 7m4s
    > kubeadm: 43.12 MiB / 43.12 MiB [------------] 100.00% 92.23 KiB p/s 7m59s
    > kubelet: 118.75 MiB / 118.75 MiB [---------] 100.00% 210.35 KiB p/s 9m38s
  - 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

四、最后验证一下

kubectl cluster-info

出现下面的错误表示安装成功:

Kubernetes control plane is running at https://127.0.0.1:59750
CoreDNS is running at https://127.0.0.1:59750/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

你可能感兴趣的:(Windows安装Minikube体验Kubernetes(k8s)集群)