为什么k8s集群中的节点连接不上?
why the node in k8s cluster cant be connected?
我在我的本地环境中按种类创建了一个集群
为什么无法连接到节点的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 公开我的服务
所以,我该如何完成这一步??
Kind 在单独的 Docker 容器中运行每个 Kubernetes 节点。您看到的 IP 地址是 Docker-内部地址,但不能直接访问(除非您从容器外部调用,在同一主机上,并且它是本地 Linux 主机)。
创建类型集群时,您需要 configure it to publish ports from the node container。为此,您需要知道正在发布的节点上的端口号;如果它是 NodePort 类型的服务,您需要知道(或者可能直接指定)nodePort:
值,例如
Istio 文档描述 looking up the ingress port but that's not too useful since you need to reinstall the cluster with that value. Istio has several installation profiles. It's very possible to customize them, including changing the Service port definitions; the Gateway definition 内容丰富,但确实允许明确设置 nodePort
值。
所以:首先,选择一个端口,在普通的NodePort范围内(30000-32767);让我们使用 31380(出现在您 link 的文档页面中的数字)。
您需要配置种类以使该端口可见:
# 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 配置。注意一定要复制the entire list of ports.
# 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
然后,在新的集群中,使用此设置安装 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-system
命名空间中的 NodePort(实际上是 LoadBalancer)istio-ingressgateway
服务;
- 转发到实际入口 Pod 上的端口 8080;
- 入口网关使用正常的 Kubernetes 和 Istio 集群内网络对您的应用程序进行基于 URL 的路由。
我在我的本地环境中按种类创建了一个集群
为什么无法连接到节点的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 公开我的服务
所以,我该如何完成这一步??
Kind 在单独的 Docker 容器中运行每个 Kubernetes 节点。您看到的 IP 地址是 Docker-内部地址,但不能直接访问(除非您从容器外部调用,在同一主机上,并且它是本地 Linux 主机)。
创建类型集群时,您需要 configure it to publish ports from the node container。为此,您需要知道正在发布的节点上的端口号;如果它是 NodePort 类型的服务,您需要知道(或者可能直接指定)nodePort:
值,例如
Istio 文档描述 looking up the ingress port but that's not too useful since you need to reinstall the cluster with that value. Istio has several installation profiles. It's very possible to customize them, including changing the Service port definitions; the Gateway definition 内容丰富,但确实允许明确设置 nodePort
值。
所以:首先,选择一个端口,在普通的NodePort范围内(30000-32767);让我们使用 31380(出现在您 link 的文档页面中的数字)。
您需要配置种类以使该端口可见:
# 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 配置。注意一定要复制the entire list of ports.
# 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
然后,在新的集群中,使用此设置安装 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-system
命名空间中的 NodePort(实际上是 LoadBalancer)istio-ingressgateway
服务; - 转发到实际入口 Pod 上的端口 8080;
- 入口网关使用正常的 Kubernetes 和 Istio 集群内网络对您的应用程序进行基于 URL 的路由。