
我已經在 Debian minikube 上成功設定了簡單的 Debian 叢集叢集 VM:
umen@debian12:~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-77c947d946-jq2s4 1/1 Running 0 45m
hello-77c947d946-wm6n2 1/1 Running 0 45m
umen@debian12:~$ minikube service list -p multinode-demo
|-------------|------------|--------------|---------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-------------|------------|--------------|---------------------------|
| default | hello | 80 | http://192.168.49.2:31000 |
| default | kubernetes | No node port | |
| kube-system | kube-dns | No node port | |
|-------------|------------|--------------|---------------------------|
umen@debian12:~$ curl http://192.168.49.2:31000
Hello from hello-77c947d946-wm6n2 (10.244.1.2)
正如你首先看到的那樣
現在在我的Windows主機中我嘗試連接這個集群我從debian伺服器下載了證書
vi ./kube/config_debian
apiVersion: v1
clusters:
- cluster:
certificate-authority: debian/ca.crt
extensions:
- extension:
last-update: Mon, 23 Oct 2023 08:54:23 IDT
provider: minikube.sigs.k8s.io
version: v1.31.2
name: cluster_info
server: https://192.168.49.2:8443
name: minikube
contexts:
- context:
cluster: minikube
extensions:
- extension:
last-update: Mon, 23 Oct 2023 08:54:23 IDT
provider: minikube.sigs.k8s.io
version: v1.31.2
name: context_info
namespace: default
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: debian/client.crt
client-key: debian/client.key
當我嘗試連接時,我得到:
$ kubectl -v=8 --kubeconfig=config_debian get pods
I1023 10:55:55.058414 16936 loader.go:372] Config loaded from file: config_debian
I1023 10:55:55.154616 16936 cert_rotation.go:137] Starting client certificate rotation controller
I1023 10:55:55.154616 16936 round_trippers.go:432] GET https://192.168.49.2:8443/api?timeout=32s
I1023 10:55:55.155136 16936 round_trippers.go:438] Request Headers:
I1023 10:55:55.155136 16936 round_trippers.go:442] Accept: application/json, */*
I1023 10:55:55.155136 16936 round_trippers.go:442] User-Agent: kubectl.exe/v1.22.0 (windows/amd64) kubernetes/c2b5237
I1023 10:56:16.186405 16936 round_trippers.go:457] Response Status: in 21031 milliseconds
I1023 10:56:16.186405 16936 round_trippers.go:460] Response Headers:
I1023 10:56:16.186405 16936 cached_discovery.go:121] skipped caching discovery info due to Get "https://192.168.49.2:8443/api?timeout=32s": dial tcp 192.168.49.2:8443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I1023 10:56:16.188079 16936 round_trippers.go:432] GET https://192.168.49.2:8443/api?timeout=32s
I1023 10:56:16.188079 16936 round_trippers.go:438] Request Headers:
I1023 10:56:16.188079 16936 round_trippers.go:442] Accept: application/json, */*
I1023 10:56:16.188079 16936 round_trippers.go:442] User-Agent: kubectl.exe/v1.22.0 (windows/amd64) kubernetes/c2b5237
I1023 10:56:37.192081 16936 round_trippers.go:457] Response Status: in 21003 milliseconds
I1023 10:56:37.192189 16936 round_trippers.go:460] Response Headers:
I1023 10:56:37.192189 16936 cached_discovery.go:121] skipped caching discovery info due to Get "https://192.168.49.2:8443/api?timeout=32s": dial tcp 192.168.49.2:8443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I1023 10:56:37.193955 16936 shortcut.go:89] Error loading discovery information: Get "https://192.168.49.2:8443/api?timeout=32s": dial tcp 192.168.49.2:8443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I1023 10:56:37.194510 16936 round_trippers.go:432] GET https://192.168.49.2:8443/api?timeout=32s
I1023 10:56:37.194510 16936 round_trippers.go:438] Request Headers:
I1023 10:56:37.195088 16936 round_trippers.go:442] Accept: application/json, */*
I1023 10:56:37.195088 16936 round_trippers.go:442] User-Agent: kubectl.exe/v1.22.0 (windows/amd64) kubernetes/c2b5237
問題是為什麼我無法連接到遠端集群
答案1
根據Github 問題 #2575,檢查連接問題的原因和緩解措施,如下所述:
檢查您是否在安裝 Docker Toolbox(使用 VirtualBox 的舊版)和 Docker for Windows(使用 Hyper-V)時遇到問題。刪除 Docker Toolbox 並重新安裝 Docker for Windows 可能有助於解決該問題。
檢查伺服器的資源是否不足:確保伺服器有足夠的資源(例如記憶體)來處理您發送的請求數量。
從認證方面嘗試以下 2 個步驟並遵循文檔minikube TLS 無需驗證,這可能有助於進一步解決您的問題:
在 virtualbox 中設定從主機 8443 到 Minikube vm 8443 的連接埠轉發
建立一個沒有 TLS 驗證的新上下文 minikube-vpn。