title: Kubernetes Cluster-IP service not working as expected
body: <p>Ok, so currently I've got kubernetes master up and running on AWS EC2 instance, and a single worker running on my laptop:</p>
  
  <pre><code>$ kubectl get nodes
  NAME            STATUS    ROLES     AGE       VERSION
  master          Ready     master    34d       v1.9.2
  worker          Ready     &lt;none&gt;    20d       v1.9.2
  </code></pre>
  
  <p>I have created a Deployment using the following configuration:</p>
  
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: hostnames
    labels:
      app: hostnames-deployment
  spec:
    selector:
      matchLabels:
        app: hostnames
    replicas: 1
    template:
      metadata:
        labels:
          app: hostnames
      spec:
        containers:
        - name: hostnames
          image: k8s.gcr.io/serve_hostname
          ports:
          - containerPort: 9376
            protocol: TCP
  </code></pre>
  
  <p>The deployment is running:</p>
  
  <pre><code>$ kubectl get deployment
  NAME           DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
  hostnames      1         1         1            1           1m
  </code></pre>
  
  <p>A single pod has been created on the worker node:</p>
  
  <pre><code>$ kubectl get pods
  NAME                           READY     STATUS    RESTARTS   AGE
  hostnames-86b6bcdfbc-v8s8l     1/1       Running   0          2m
  </code></pre>
  
  <p>From the worker node, I can curl the pod and get the information:</p>
  
  <pre><code>$ curl 10.244.8.5:9376
  hostnames-86b6bcdfbc-v8s8l
  </code></pre>
  
  <p>I have created a service using the following configuration:</p>
  
  <pre><code>kind: Service
  apiVersion: v1
  metadata:
    name: hostnames-service
  spec:
    selector:
      app: hostnames
    ports:
    - port: 80
      targetPort: 9376
  </code></pre>
  
  <p>The service is up and running:</p>
  
  <pre><code>$ kubectl get svc
  NAME                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
  hostnames-service   ClusterIP   10.97.21.18      &lt;none&gt;        80/TCP         1m
  kubernetes          ClusterIP   10.96.0.1        &lt;none&gt;        443/TCP        34d
  </code></pre>
  
  <p>As I understand, the service should expose the pod cluster-wide and I should be able to use the service IP to get the information pod is serving from any node on the cluster.</p>
  
  <p>If I curl the service from the worker node it works just as expected:</p>
  
  <pre><code>$ curl 10.97.21.18:80
  hostnames-86b6bcdfbc-v8s8l
  </code></pre>
  
  <p>But if I try to curl the service from the master node located on the AWS EC2 instance, the request hangs and gets timed out eventually:</p>
  
  <pre><code>$ curl -v 10.97.21.18:80
  * Rebuilt URL to: 10.97.21.18:80/
  *   Trying 10.97.21.18...
  * connect to 10.97.21.18 port 80 failed: Connection timed out
  * Failed to connect to 10.97.21.18 port 80: Connection timed out
  * Closing connection 0
  curl: (7) Failed to connect to 10.97.21.18 port 80: Connection timed out
  </code></pre>
  
  <p><strong>Why can't the request from the master node reach the pod on the worker node by using the Cluster-IP service?</strong></p>
  
  <p>I have read quite a bit of articles regarding kubernetes networking and the official kubernetes services documentation and couldn't find a solution.</p>