<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><strong>Routes</strong> are an <strong>OpenShift-specific</strong> way of exposing a Service outside the cluster.
But, if you are developing an app that will be deployed onto <strong>OpenShift and Kubernetes</strong>, then you should use <strong>Kubernetes Ingress</strong> objects.</p>
<p>Using Ingress means that your app’s manifests are more portable between different Kubernetes clusters.</p>
<p>From the <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">official Kubernetes docs</a>:</p>
<blockquote>
<ul>
<li>An Ingress may be configured to give Services externally-reachable URLs, load balance traffic, terminate SSL / TLS, and offer name-based virtual hosting.</li>
<li>Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.</li>
<li>Traffic routing is controlled by rules defined on the Ingress resource.</li>
</ul>
</blockquote>
<h4>So, if you want to reach your REST controllers:</h4>
<ul>
<li><strong>from within the k8s cluster</strong>. Create a k8s <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Service</a> to expose an application running on a set of Pods as a network service:</li>
</ul>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: your-namespace
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
</code></pre>
<p>This specification creates a new Service object named &quot;my-service&quot;, which targets TCP port 8080 on any Pod with the <code>app=MyApp</code> label.
You can reach the REST controller using this URL:</p>
<pre><code>http://my-service
</code></pre>
<ul>
<li><strong>externally</strong>. Create an <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Ingress resource</a> to configure externally-reachable URLs (a k8s Service 'my-service' should exist):</li>
</ul>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-name
  namespace: your-namespace
spec:
  rules:
  - host: &quot;foo.bar.com&quot;  
    http:
      paths:
      - pathType: Prefix
        path: &quot;/&quot;
        backend:
          service:
            name: my-service
            port:
              number: 80
</code></pre>
<p>You can reach the REST controller using this URL:</p>
<pre><code>http://foo.bar.com
</code></pre>
