gpt4 book ai didi

kubernetes - GKE NodePort服务拒绝传入流量

转载 作者:行者123 更新时间:2023-12-02 12:11:03 30 4
gpt4 key购买 nike

我已经在Google云中创建了具有以下规范的节点端口服务...我创建了防火墙规则,以允许端口'30100'的流量从0.0.0.0/0开始,我已经验证了堆栈驱动程序日志,并且在发生流量时我使用curl或从浏览器中击中http://:30100我没有得到任何回应。我也无法继续调试问题...有人可以对此提出建议吗?

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginxv1
template:
metadata:
labels:
app: nginxv1
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: nginxv1
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 8080
nodePort: 30100
selector:
app: nginxv1
type: NodePort

谢谢。

最佳答案

您需要修复容器端口,它必须为80,因为nginx容器公开了此端口,如您所见here

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginxv1
template:
metadata:
labels:
app: nginxv1
spec:
containers:
- name: nginx
image: nginx:latest
---
apiVersion: v1
kind: Service
metadata:
name: nginxv1
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
nodePort: 30100
selector:
app: nginxv1
type: NodePort
另外,您需要创建防火墙规则以允许流量进入节点,如@danyL在评论中所述:
gcloud compute firewall-rules create test-node-port --allow tcp:30100
使用命令获取节点IP
kubectl get nodes -owide
他们尝试通过以下方式访问nginx页面:
curl http://<NODEIP>:30100

关于kubernetes - GKE NodePort服务拒绝传入流量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62974497/

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