我有两个容器(Nginx和Busybox)在同一命名空间的不同容器中运行。每当我尝试从busybox pod到Nginx进行ping或wget时,我都无法做到这一点,并且我无法理解为什么会发生这种情况,因为我应该能够从Pod与另一个进行通信。
Ngnix Pod说明
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx
name: nginx
ports:
- containerPort: 80
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
BusyBox Pod说明
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: busybox
name: busybox
spec:
containers:
- image: busybox
name: busybox
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Never
status: {}
终端放置:
wget -O- 172.XX.XX.XXX:XX
Connecting to 172.XX.XX.XXX:XX (172.XX.XX.XXX:XX)
wget: can't connect to remote host (172.XX.XX.XXX): Connection timed out
在登录时我得到了
2019/07/12 18:47:30 [error] 7#0: *1177 "/usr/local/nginx/html/nginx_status/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /nginx_status/ HTTP/1.1", host: "localhost"
答案 0 :(得分:0)
您提到的nginx日志中的404错误看起来像来自客户端客户端说的localhost
一样来自nginx主机。它与您的连接超时错误无关。
您如何找到Pod的群集IP?通常,您可以使用以下命令获取IP地址:
kubectl get pods -o wide
检查wget命令中使用的IP是否正确。