为什么我不能从其他Node IP访问kubernetes pod? [英] Why I cant access a kubernetes pod from other Nodes IP?

查看:503
本文介绍了为什么我不能从其他Node IP访问kubernetes pod?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Kubespray的帮助下安装了kubernetes集群. 具有3个节点的群集(2个主节点和1个工作节点). 节点1-10.1.10.110, 节点2-10.1.10.111, 节点3-10.1.10.112

I've installed kubernetes cluster with help of Kubespray. Cluster having 3 Nodes (2 Master & 1 Worker). node1 - 10.1.10.110, node2 - 10.1.10.111, node3 - 10.1.10.112

$ kubectl get nodes
NAME    STATUS   ROLES    AGE   VERSION
node1   Ready    master   12d   v1.18.5
node2   Ready    master   12d   v1.18.5
node3   Ready    <none>   12d   v1.18.5

我将这个pod部署在node1(10.1.10.110)中,并如图所示公开了nodeport服务.

I deployed this pod in node1 (10.1.10.110) and exposed nodeport service as shown.

NAMESPACE     NAME                                              READY   STATUS    RESTARTS   AGE     IP             NODE    NOMINATED NODE   READINESS GATES

default       pod/httpd-deployment-598596ddfc-n56jq             1/1     Running   0          7d21h   10.233.64.15   node1   <none>           <none>
---
NAMESPACE     NAME                                TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                  AGE     SELECTOR

default       service/httpd-service               NodePort    10.233.16.84    <none>        80:31520/TCP             12d     app=httpd

服务说明

$ kubectl describe services -n default httpd-service
Name:                     httpd-service
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=httpd
Type:                     NodePort
IP:                       10.233.16.84
Port:                     <unset>  80/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  31520/TCP
Endpoints:                10.233.64.15:80
Session Affinity:         None
External Traffic Policy:  Cluster

问题: 我可以从节点1:31520(实际部署Pod的地方)访问该服务,但不能从其他节点(节点2:31520(或节点3:31520))访问相同的服务

Question: I can able to access the service from node1:31520 (where the pod actually deployed) but can't able to access the same service from other nodes (node2:31520 (or) node3:31520)

$curl http://10.1.10.110:31520
<html><body><h1>It Works!</h1></body></html>

but if I curl with other node IP, timed out response

$curl http://10.1.10.111:31520
curl (7): Failed connect to 10.1.10.111; Connection timed out

$curl http://10.1.10.112:31520
curl (7): Failed connect to 10.1.10.112; Connection timed out

任何人都可以建议我所缺少的吗?

Can anyone suggest what I am missing ?

推荐答案

因为您在10.1.10.110上只有一个吊舱

Because you have only one pod on 10.1.10.110

您的卷曲错误,您没有在111和112节点上部署Pod,这就是端点不起作用的原因.只需在其他节点上执行curl http://10.1.10.110:31520,它将起作用

Your curl is wrong, you didn't deploy a pod on 111 and 112 nodes, this is the reason that the endpoints aren't working. Just execute curl http://10.1.10.110:31520 on the other nodes and it will work

这篇关于为什么我不能从其他Node IP访问kubernetes pod?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆