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'.

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容