Unable to get a response from nginx pod when pinged through a busybox pod

7/12/2019

I have two containers (Nginx and Busybox) running in different pods in the same namespace. Whenever I try to get a ping or wget from busybox pod to Nginx I am unable to do that and I not able to understand why is this happening as I should be able to communicate from pod to another.

Ngnix Pod Description

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 Description

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busybox
  name: busybox
spec:
  containers:
  - image: busybox
    name: busybox
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

Terminal Respose:

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

On loging I get this

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"
-- Kunal Malhotra
kubernetes

1 Answer

7/12/2019

Looks like the 404 error in nginx logs mentioned by you comes from the nginx host as the client says localhost. It has nothing to do with your connection timeout error.

How did you find the cluster IP of the pod? Usually, you can get the ip address with the command:

kubectl get pods -o wide

Check if you are using the correct ip in the wget command.

-- Malathi
Source: StackOverflow