<p>I have been using Openshift/Kubernates for some time and this has been the understanding.
For service to service communication</p>
<ul>
<li>use DNS name of <code>${service-name}</code> if they are under the same namespace</li>
<li>use DNS name of <code>${service-name}.${namespace}.svc.cluster.local</code> if they are from different namespaces (network is joined)</li>
</ul>
<p>Recently i was introduced with the topic of &quot;we should add a dot after the svc.cluster.local to make it FQDN, for better DNS lookup speed&quot;. Done some testing and indeed with lookup is much faster with the dot. (~100ms without dot, 10ms with dot)</p>
<p>After some research, it was caused by the default dns setting from the kubernates</p>
<pre><code>sh-4.2$ cat /etc/resolv.conf
search ${namespace}.svc.cluster.local svc.cluster.local cluster.local
nameserver X.X.X.X
options ndots:5
</code></pre>
<p>the ndots = 5 will perform a local search (sequential) if the dns name does not contain 5 dots.
In the case of <code>${service-name}.${namespace}.svc.cluster.local</code>, the local search will be as such</p>
<ol>
<li><code>${service-name}.${namespace}.svc.cluster.local</code> + <code>${namespace}.svc.cluster.local</code> // FAILED LOOKUP</li>
<li><code>${service-name}.${namespace}.svc.cluster.local</code> + <code>svc.cluster.local</code> // FAILED LOOKUP</li>
<li><code>${service-name}.${namespace}.svc.cluster.local</code> + <code>cluster.local</code> // FAILED LOOKUP</li>
<li><code>${service-name}.${namespace}.svc.cluster.local</code> // SUCCESS LOOKUP</li>
</ol>
<p>And for <code>${service-name}.${namespace}.svc.cluster.local.</code>, the local search will be as such</p>
<ol>
<li><code>${service-name}.${namespace}.svc.cluster.local</code> // SUCCESS LOOKUP</li>
</ol>
<p>References</p>
<ol>
<li><a href="https://pracucci.com/kubernetes-dns-resolution-ndots-options-and-why-it-may-affect-application-performances.html" rel="nofollow noreferrer">link</a></li>
<li><a href="https://rcarrata.com/openshift/dns-deep-dive-in-openshift/" rel="nofollow noreferrer">how to debug</a></li>
</ol>
<p>Questions:</p>
<ol>
<li>Since the <code>ndots = 5</code> is the default setting for kubernetes, why <code>${service-name}.${namespace}.svc.cluster.local.</code> is not documented on the official side ?</li>
<li>Should we change all service call to <code>${service-name}.${namespace}.svc.cluster.local.</code> ? any potential downsides ?</li>
</ol>

bLaXjack
<blockquote>
<p>Since the <code>ndots = 5</code> is the default setting for kubernetes, why
<code>${service-name}.${namespace}.svc.cluster.local.</code> is not documented on
the official side ?</p>
</blockquote>
<p>Well, it's a really good question. I searched through the official docs and it looks like this is not a documented feature. For this reason much better place for posting your doubts and also request for documentation improvement is the official <strong>GitHub</strong> site of <a href="https://github.com/kubernetes/dns" rel="nofollow noreferrer">Kubernetes DNS</a>.</p>
<blockquote>
<p>Should we change all service call to
<code>${service-name}.${namespace}.svc.cluster.local.</code> ? any potential
downsides ?</p>
</blockquote>
<p>If it works well for you and definitely increases the performance, I would say <em>- Why not ?</em> I can't see any potential downsides here. By adding the last dot you're simply omitting those first 3 lookups that are doomed to failure anyway if you use <code>Service</code> domain name in a form of <code>${service-name}.${namespace}.svc.cluster.local</code></p>
<p>Inferring from lookup process you described and your tests, I guess if you use only <code>${service-name}</code> (of course only within the same <code>namespace</code>), dns lookup should be also much faster and closer to those <code>10ms</code> you observed when using <code>${namespace}.svc.cluster.local svc.cluster.local cluster.local.</code> as then it is matched in the very first iteration.</p>
