<p>I have an openshift namespace (<code>SomeNamespace</code>), in that namespace I have several pods.</p>
<p>I have a route associated with that namespace (<code>SomeRoute</code>).</p>
<p>In one of pods I have my spring application. It has REST controllers.</p>
<p>I want to send message to that REST controller, how can I do it?</p>
<p>I have a route URL: <code>https://some.namespace.company.name</code>. What should I find next?</p>
<p>I tried to send requests to <code>https://some.namespace.company.name/rest/api/route</code> but it didn't work. I guess, I must somehow specify pod in my URL, so route will redirect requests to concrete pod but I don't know how I can do it.</p>

<p>You don't need to specify the pod in the route.</p>
<p>The chain goes like this:</p>
<ul>
<li><code>Route</code> exposes a given port of a <code>Service</code></li>
<li><code>Service</code> selects some pod to route the traffic to by its <code>.spec.selector</code> field</li>
</ul>
<p>You need to check your <code>Service</code> and <code>Route</code> definitions.</p>
<p>Example service and route (including only the related parts of the resources):</p>
<p><code>Service</code></p>
<pre><code>spec:
  ports:
  - name: 8080-tcp
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    &lt;label-key&gt;: &lt;label-value&gt;
</code></pre>
<p>Where <code>label-key</code> and <code>label-value</code> is any label key-value combination that selects your pod with the http application.</p>
<p><code>Route</code></p>
<pre><code>spec:
  port:
    targetPort: 8080-tcp &lt;port name of the service&gt;
  to:
    kind: Service
    name: &lt;service name&gt;
</code></pre>
<p>When your app exposes some endpoint on <code>:8080/rest/api</code>, you can invoke it with <code>&lt;route-url&gt;/rest/api</code></p>
<p>You can try it out with some example application (some I found randomly on github, to verify everything works correctly on your cluster):</p>
<ul>
<li><p>create a new app using s2i build from github repository: <code>oc new-app registry.redhat.io/openjdk/openjdk-11-rhel7~https://github.com/redhat-cop/spring-rest</code></p>
</li>
<li><p>wait until the s2i build is done and the pod is started</p>
</li>
<li><p>expose the service via route: <code>oc expose svc/spring-rest</code></p>
</li>
<li><p>grab the route url: <code>oc get route spring-rest -o jsonpath='{.spec.host}'</code></p>
</li>
<li><p>invoke the api: <code>curl -k &lt;route-url&gt;/v1/greeting</code></p>
</li>
<li><p>response should be something like: <code>{&quot;id&quot;:3,&quot;content&quot;:&quot;Hello, World!&quot;}</code></p>
</li>
</ul>
