Answers: <p>Your <code>/etc/resolve.conf</code> should include <code>search &lt;currentnamespace&gt;.svc.cluster.local svc.cluster.local cluster.local</code> to discover hostnames that aren't FQDN.</p>
  <p>As an example, this is the content of my pod's <code>/etc/resolve.conf</code>:</p>
  <pre><code>nameserver 10.100.0.10
  search staging.svc.cluster.local svc.cluster.local cluster.local eu-west-1.compute.internal
  </code></pre>
  <p>With this configuration, DNS resolution works like this:</p>
  <ol>
  <li>Is the hostname a fully qualified domain name (FQDN)? (In other words, does it end with a dot, like &quot;google.com.&quot;)</li>
  <li>If it's an FQDN, query nameserver (<code>10.100.0.10</code>) for the hostname.</li>
  <li>If it's not an FQDN, then append the <strong>1st</strong> element of the config <strong>search</strong> to the hostname. <code>svcname</code> -&gt; <code>svcname.staging.svc.cluster.local</code> and query the nameserver.</li>
  <li>If no results found, try to append the <strong>2nd</strong> element of the config <strong>search</strong> to the hostname and query the nameserver.</li>
  <li>...</li>
  </ol>
  <p>You want to resolve the hostname <code>svcname</code> but its FQDN is <code>svcname.&lt;namespace&gt;.svc.cluster.local.</code> and you need that <strong>search</strong> configuration to convert it to FQDN.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-02-22T20:49:14.263Z
Answers: 2021-02-22T20:49:14.263Z
Answers: yozel
Body: <p>I cannot access a pod from another pod with its service name. Getting error as</p>
  <blockquote>
  <p>cannot resolve host <code>svcname</code></p>
  </blockquote>
  <p>When i try to view the information of /etc/resolv.conf, i do see ec2.internal as searches and ndots as 1. What does this means and how do i solve this to access a pod from another pod with the service name.</p>
  
Comments: CC BY-SA 4.0
Comments: 2021-01-01T12:39:50.477Z
Comments: can you show us the URL format you trying to reach? are you using `.local`?
Comments: Saikat Chakrabortty
Tags: <docker><kubernetes><deployment><networking>
Title: Cannot resolve services with service name inside a kubernetes pod
UserDisplayName: ADHITHYA SRINIVASAN
ThreadText: # Cannot resolve services with service name inside a kubernetes pod
  
  (Asked by: username_0 on 2020-12-31)
  
  I cannot access a pod from another pod with its service name. Getting error as
  
  > cannot resolve host `svcname`
  
  When i try to view the information of /etc/resolv.conf, i do see ec2.internal as searches and ndots as 1. What does this means and how do i solve this to access a pod from another pod with the service name.
  
  **Tags:** docker, kubernetes, deployment, networking
  
  > **Comments:**
  > **username_1**: can you show us the URL format you trying to reach? are you using `.local`?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-02-22. Score: 0
  
  Your `/etc/resolve.conf` should include `search <currentnamespace>.svc.cluster.local svc.cluster.local cluster.local` to discover hostnames that aren't FQDN.
  
  As an example, this is the content of my pod's `/etc/resolve.conf`:
  
  ```
  nameserver 10.100.0.10
  search staging.svc.cluster.local svc.cluster.local cluster.local eu-west-1.compute.internal
  
  ```
  
  With this configuration, DNS resolution works like this:
  
  1. Is the hostname a fully qualified domain name (FQDN)? (In other words, does it end with a dot, like "google.com.")
  2. If it's an FQDN, query nameserver (`10.100.0.10`) for the hostname.
  3. If it's not an FQDN, then append the **1st** element of the config **search** to the hostname. `svcname` -> `svcname.staging.svc.cluster.local` and query the nameserver.
  4. If no results found, try to append the **2nd** element of the config **search** to the hostname and query the nameserver.
  5. ...
  
  You want to resolve the hostname `svcname` but its FQDN is `svcname.<namespace>.svc.cluster.local.` and you need that **search** configuration to convert it to FQDN.
  
  
  ---
  
  