gpt4 book ai didi

amazon-eks - AWS-EKS 部署的 pod 以类型服务公开节点端口无法通过节点端口 IP 和公开端口访问

转载 作者:行者123 更新时间:2023-12-04 17:40:31 33 4
gpt4 key购买 nike

我使用 EKS 和 Terraform 在 AWS 上创建了 k8s 集群,遵循此文档 https://docs.aws.amazon.com/eks/latest/userguide/what-is-eks.html .

我有一个工作节点注意:一切都在私有(private)子网中

只是运行 node.js hello-world 容器

pod 定义代码

kind: Pod
metadata:
name: nodehelloworld.example.com
labels:
app: helloworld
spec:
containers:
- name: k8s-demo
image: wardviaene/k8s-demo
ports:
- name: nodejs-port
containerPort: 3000

服务定义代码

apiVersion: v1
kind: Service
metadata:
name: helloworld-service
spec:
ports:
- port: 31001
nodePort: 31001
targetPort: nodejs-port
protocol: TCP
selector:
app: helloworld
type: NodePort

kubectl get pods 显示我的 pod 已启动并正在运行

nodehelloworld.example.com   1/1       Running   0          17h

kubectl get svc 显示我的服务也创建好了

helloworld-service   NodePort    172.20.146.235   <none>        31001:31001/TCP   16h

kubectl describe svc helloworld-service 它有正确的端点和正确的选择器

问题来了

当我点击 NodeIP:exposed 端口(即 31001)时,我得到了 This site can't be reached

然后我使用了kubeclt port-forward podname 3000:3000

我可以用 curl -v localhost:3000 访问

我检查了我的安全组入站规则是来 self 的 CIDR block 的 0-65535。

还有什么我想念的吗?

最佳答案

如果您尝试从集群外部连接,那么在工作节点的安全组中,您将必须添加自定义 TCP 条目以启用端口 31001 上的入站流量。 Add an entry to Inbound rules in your worker node security group

如果这不起作用,请确保您能够通过该 IP 连接到节点。我通常使用 VPN 客户端连接。

关于amazon-eks - AWS-EKS 部署的 pod 以类型服务公开节点端口无法通过节点端口 IP 和公开端口访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54698505/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com