Cannot access a cluster IP from internally from another pod: Connection refused

Viewed 272

I'm using Docker Desktop Kubernetes on Windows, and I cannot access a ClusterIP service internally from another pod. This is what i deployed:

$ k get pods -o wide

my-nginx-deploy-d78b588bf-cffmd 1/1 Running 0 83s 10.1.0.123 docker-desktop

my-nginx-deploy-d78b588bf-m945j 1/1 Running 0 83s 10.1.0.122 docker-desktop

$ k get services -o wide

nginx-service ClusterIP 10.103.79.175 8818/TCP 22m app=nginx

I'm checking internal connectivity running a shell in one of the pods and sending a requesto to the service (by name and by IP) an directly to the pod:

& k exec -ti my-nginx-deploy-d78b588bf-cffmd -- /bin/sh

curl nginx-service:8818

  curl: (7) Failed to connect to nginx-service port 8818 after 21031 ms: Connection refused

curl 10.103.79.175:8818

  curl: (7) Failed to connect to nginx-service port 8818 after 21031 ms: Connection refused

curl 10.1.0.122

  <!DOCTYPE html>
  <html>
  <head>
  <title>Welcome to nginx!</title>
  ...
  </html>

So the pod is running and can be accesed using the pod IP, but the service is rejecting connections.

This is the yaml of the service:

$ k get service nginx-service -o yaml

apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
clusterIP: 10.103.79.175
clusterIPs:

  • 10.103.79.175
    internalTrafficPolicy: Cluster
    ipFamilies:
  • IPv4
    ipFamilyPolicy: SingleStack
    ports:
  • name: nginx-port
    port: 8818
    protocol: TCP
    targetPort: 80
    selector:
    app: nginx
    sessionAffinity: None
    type: ClusterIP
    status:
    loadBalancer: {}

What could be the reason? how can I dig into the problem?

0 Answers
Related