<p>I have a requirement to convert a multipod setup to a single pod with multiple container. I had pod x running x microservice and pod y running y microservice with below rest endpoint.</p>
<ul>
<li><code>http://x:8080/{context path-x}/endpoint</code></li>
<li><code>http://y:8080/{context path-y}/endpoint</code></li>
</ul>
<p>I want to have pod z with x and y microservice with container x exposed on 8080 port and y on 8081 within same pod. I am able to achieve these with multi-container pod.</p>
<p>My problem is now the URL are changed</p>
<ul>
<li><code>http://z:8080/{context path-x}/endpoint</code></li>
<li><code>http://z:8081/{context path-y}/endpoint</code></li>
</ul>
<p>I am looking for way in which I can hit endpoints without the change is URL or minimum hit with below URLs</p>
<ul>
<li><code>http://x:8080/{context path-x}/endpoint</code></li>
<li><code>http://y:8081/{context path-y}/endpoint</code></li>
</ul>
<p>My real project requirement has 5 container on single pods and has 100s of endpoints exposed</p>
<p>How can I achieve this?</p>

NAGESH KAMAT
<p>K8s services are the way to expose your application. Since you have two applications and want to run them as two different containers inside a single Pod and you want minimum changes in your application API URL, then simply create create two different Services having your trageted ports. Thus you need 0 changes in your application's APP url.</p>
<p>In K8s cluster, you can use simply the name of the service name as the host name from the same namespace. You can see <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">FQDN (fully qualified domain name) convention for a service</a>.</p>
<p>Hence, you can create two Services with name <code>x</code> and <code>y</code>, where <code>x</code> have the port 8080 and <code>y</code> have the port 8081. Thus you can use the same urls as before.</p>
<blockquote>
<p>NOTE: There may exist different ways to achieve one's goal(s) but may arise different issues.</p>
</blockquote>
