我在本地環境中按種類創建了一個集群
為什么節點的ip串列無法連接?喜歡底部
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
kind-control-plane Ready control-plane,master 22h v1.21.1 172.18.0.2 <none> Ubuntu 21.04 4.19.121-linuxkit containerd://1.5.2
ping 172.18.0.2 得到 Request timeout
我遵循檔案https://istio.io/latest/docs/setup/getting-started/并在步驟中被阻止Verify external access
“http://$GATEWAY_URL/productpage”對我來說不是一個有用的網站
我遇到了這個問題,所以當我在本地測驗 istio 時,無法從 pod 內部公開我的服務
那么,我該如何完成這一步??
uj5u.com熱心網友回復:
Kind 在單獨的 Docker 容器中運行每個 Kubernetes 節點。您看到的 IP 地址是 Docker 內部地址,但不能直接訪問(除非您從容器外部、同一主機上呼叫,并且它是本機 Linux 主機)。
當您創建種類集群時,您需要將其配置為從節點容器發布埠。為此,您需要知道正在發布的節點上的埠號;例如,如果它是 NodePort 型別的服務,則您需要知道(或可能直接指定)該nodePort:值。
Istio 檔案描述了查找入口埠,但這不是很有用,因為您需要使用該值重新安裝集群。Istio 有幾個安裝組態檔。自定義它們是非常可能的,包括更改服務埠定義;該網關定義是巨大的,但允許明確設定的nodePort值。
所以:首先,選擇一個埠,在普通的 NodePort 范圍內(30000-32767);讓我們使用 31380(出現在您鏈接到的檔案頁面中的數字)。
您需要配置 kind 以使該埠可見:
# kindconfig.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 31380 # actually the nodePort
hostPort: 8000 # some available port on your host (can be 80)
創建集群
kind create cluster --config=kindconfig.yaml
創建 Istio 配置。請注意,您必須復制整個埠串列。
# istioconfig.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
components:
ingressGateways:
- name: istio-ingressgateway
enabled: true
k8s:
service:
ports:
- port: 15021
targetPort: 15021
name: status-port
- port: 80
targetPort: 8080
nodePort: 31380 # <-- add this
name: http2
# and copy the remaining ports from the reference config
然后,在新的 kind 集群中,使用此設定安裝 Istio
istioctl install --set profile=demo -f istioconfig.yaml
一旦 Istio 完全啟動并部署應用程式,您應該能夠http://localhost:8000從主機系統訪問,其中 8000 是hostPort:我們配置的型別設定(如果您在那里選擇了埠 80,則可以省略埠號)。
這里的路由是:
localhost來自主機的埠 8000 到達 Docker 埠轉發;- Docker轉發到
kind-control-plane容器中的31380埠; - 埠 31380 附加到命名空間
istio-ingressgateway中的一個 NodePort(實際上是 LoadBalancer)服務istio-system; - 轉發到實際入口 Pod 上的 8080 埠;
- Ingress 網關使用普通的 Kubernetes 和 Istio 集群內網路對您的應用程式進行基于 URL 的路由。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/323708.html
標籤:Kubernetes 伊斯蒂奥
