<p>I try to run elasticsearch and kibana on kubernetes. I ran:</p>

<pre><code>kubectl run elasticsearch --image=elasticsearch:6.6.1 --env="discovery.type=single-node" --port=9200 --port=9300
kubectl run kibana --image=kibana:6.6.1 --port=5601
</code></pre>

<p>then I ran <code>$kubectl proxy</code>, </p>

<pre><code>http://localhost:$IP_FROM_KUBECTL_PROXY(usually 8081)/api/v1/namespaces/default/pods/$POD_NAME/proxy/
</code></pre>

<p>When I entered to elasticsearch pod, everything looks fine, but when I entered to kibana, the app didn't work (I see "Kibana server is not ready yet" for infinity).</p>

<p>The logs of kibana are the following:</p>

<pre><code>{"type":"log","@timestamp":"2019-03-02T10:38:47Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}
{"type":"log","@timestamp":"2019-03-02T10:38:49Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}
</code></pre>

<p>This is kibana.yml on kibana pod:</p>

<h1>Default Kibana configuration from kibana-docker.</h1>

<pre><code>server.name: kibana
server.host: "0"
elasticsearch.url: http://elasticsearch:9200
xpack.monitoring.ui.container.elasticsearch.enabled: true
</code></pre>

<p>I'm pretty new with Kubernetes, and I can't figure out why they can't talk one to another. </p>

<p>This Kibana log entry explains to you what the problem is:</p>
<blockquote>
<p>{&quot;type&quot;:&quot;log&quot;,&quot;@timestamp&quot;:&quot;2019-03-02T10:38:49Z&quot;,&quot;tags&quot;:[&quot;warning&quot;,&quot;elasticsearch&quot;,&quot;admin&quot;],&quot;pid&quot;:1,&quot;message&quot;:&quot;Unable to revive connection: http://elasticsearch:9200/&quot;}</p>
</blockquote>
<p>Problem: Naming your pod elasticsearch is not enough for kubernetes.</p>
<p>You have a few solutions to fix it depending on the situation:</p>
<ol>
<li><p>Create a service as <a href="https://stackoverflow.com/users/1626280/amityo">Amityo</a> has suggested. This is enough if kibana and elasticsearch are running in the same namespace.</p>
</li>
<li><p>If kibana and elasticsearch are running in different namespaces you'll need to use the full DNS name for service: elasticsearch.my-namespace.svc.cluster.local</p>
</li>
<li><p>If you run elasticsearch and kibana in the same pod. Then localhost:9200 will be enough to be able to query.</p>
</li>
<li><p>For your current situation. When elasticsearch is running you can use as ELASTICSEARCH_URL the pod DNS name: 1-2-3-4.default.pod.cluster.local when 1-2-3-4 is IP address of pod with dots replaced by dashes.</p>
</li>
</ol>
<p>You can define the hostname when you create a Pod definition for elasticsearch using the following YAML:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: elasticsearch
  labels:
    name: elasticsearch-single
spec:
  hostname: elasticsearch
  subdomain: for-kibana
  containers:
  - image: elasticsearch:6.6.1
    name: elasticsearch
</code></pre>
<p>Then you will be able to use as ELASTICSEARCH_URL the pod DNS name: elasticsearch.for-kibana.default.svc.cluster.local service.</p>
<p>All information you can find on kubernetes doc <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">here</a></p>
<p><strong>Please note:</strong> According to official docs the Env variable ELASTICSEARCH_URL is deprecated in newer elasticsearch versions, more details <a href="https://www.elastic.co/guide/en/kibana/7.x/breaking-changes-7.0.html#_elasticsearch_url_is_no_longer_valid" rel="nofollow noreferrer">see here</a></p>
