<p>When you create a kubernetes service named <code>myservice</code>, you can access that service in your pods with urls like this: <code>http://myservice/media/images/...</code>.</p>
<p>Is it possible to make urls like <code>/media/images/...</code> get resolved to urls like <code>http://myservice/media/images/...</code> in a specific kubernetes pod?</p>
<p>For example suppose we have a pod named &quot;podA&quot;. Is it possible for containers in &quot;podA&quot; to send GET requests with urls like <code>/media/images/...</code> instead of urls like <code>http://myservice/media/images/...</code> ?</p>

HsnVahedi
<p>Answering the following question:</p>
<blockquote>
<p>Is it possible to make urls like /media/images/... get resolved to urls like http://myservice/media/images/... in a specific kubernetes pod?</p>
</blockquote>
<p><strong>In short, no</strong>.</p>
<p>Take a look on following example:</p>
<pre><code>http://awesomeservice/folder/sample.txt
\__/   \_______________/\_______/
 |            |             |
protocol  service name    path to 
                          resource 
</code></pre>
<p>When you try to send a web request for a specific resource (from your Kubernetes <code>Pod</code>) you <strong>need</strong> to have a host part. If you tried like: <code>/media/images/...</code> you would be telling your OS/software/application that you want a resource from a local filesystem.</p>
<p>You can read more on the topic on how the <code>Pods</code> can communicate with each other by following this documentation:</p>
<ul>
<li><em><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Kubernetes.io: Docs: Concepts: Services networking: Service</a></em></li>
</ul>
<hr />
<p>As a <strong>workaround</strong> to have an access to your resources on path like <code>/media/images/...</code> you could provision the storage solution that would be mounted to your <code>/media</code> catalogue. There are multiple ways to achieve that and you would need to refer to the specific solution documentation (it will be different on-premises and in the cloud-managed Kubernetes cluster). As a starting point/baseline you can look on:</p>
<ul>
<li><em><a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Kubernetes.io: Docs: Concepts: Storage: Persistent Volumes</a></em></li>
</ul>
<hr />
<p>Giving more visibility to the useful comments made under the question:</p>
<blockquote>
<p>Path-only URLs are usually resolved with respect to some base URL and inherit the hostname from that base; how would your &quot;podA&quot; code know what that base URL is? Can you provide more specific code that demonstrates what you need and why you want to omit the hostname part of the URL? – David Maze</p>
</blockquote>
<blockquote>
<p>AFAIK from pure Kubernetes perspective this won't be possible. You would need to have some type of <code>base_url</code> provided to your <code>Pod</code> which is requesting the content. – Dawid Kruk</p>
</blockquote>
<hr />
<p>Additional resources:</p>
<ul>
<li><em><a href="https://en.wikipedia.org/wiki/Uniform_Resource_Identifier" rel="nofollow noreferrer">Wikipedia.org: Uniform resource identifier</a></em></li>
<li><em><a href="https://en.wikipedia.org/wiki/Path_(computing)" rel="nofollow noreferrer">Wikipedia.org. Wiki: Path (computing)</a></em></li>
</ul>
<blockquote>
<p><strong>Side note!</strong></p>
<p>As for:</p>
<blockquote>
<p>Is it possible to make urls like /media/images/... get resolved to urls like http://myservice/media/images/... in a specific kubernetes pod?</p>
</blockquote>
<p>If you were thinking about sending the request to a <strong>specific</strong> <code>Pod</code> you could look on:</p>
<ul>
<li><em><a href="https://istio.io/latest/docs/concepts/traffic-management/" rel="nofollow noreferrer">Istio.io: Latest: Docs: Concepts: Traffic management</a></em></li>
</ul>
</blockquote>
