<p>I have Elasticsearch Pod, and a Service. I also have another Pod (same namespace - default) called "website", that want to get the html content of the Elasticsearch (using curl). </p>

<p>When I access the "website" Pod (using exec), and run <code>$curl -v elasticsearch-service</code>,I get:</p>

<pre><code>curl -v elasticsearch-service
* Rebuilt URL to: elasticsearch-service/
*   Trying 10.111.159.30...
* TCP_NODELAY set
</code></pre>

<p>note: 10.111.159.30 is the elasticsearch-service IP.</p>

<p>But when I run <code>$curl 172.15.0.5:9200</code> (POD IP), I get the correct output:</p>

<pre><code> $curl 172.15.0.5:9200
{
  "name" : "1X7ZARS",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "V8GX-5STSoW_PJ8Qguu7Jw",
  "version" : {
    "number" : "6.6.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "1fd8f69",
    "build_date" : "2019-02-13T17:10:04.160291Z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
</code></pre>

<p>For some reason, Elasticsearch's service, doesn't redirect to the els app.</p>

<p>This is the yaml of the Pod:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: elasticsearch
spec:
  containers:
  - name: elasticsearch
    image: yageldhn/els-java8:6.6.1
    ports:
    - containerPort: 9200
    - containerPort: 9300
    env:
    - name: discovery.type
      value: "single-node"
</code></pre>

<p>This is the yaml of the service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: elasticsearch-service
spec:
  ports:
  - port: 9200
    name: serving
    protocol: TCP
  - port: 9300
    name: node2node
    protocol: TCP
  selector:
    app: elasticsearch
</code></pre>

<p>I'm pretty new with K8s, what I did wrong?</p>

Yagel
<p>You need to label your pod with <em>app: elasticsearch</em> because of the selector in you service definition:
    <code>selector:
      app: elasticsearch</code></p>

<p>Edit: There is a pretty good explanation in the official <a href="https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service" rel="nofollow noreferrer">docs</a> </p>
