<p>I have a spring cloud gateway that works fine in the docker configuration, like this:
(all routes/services except ratings are removed for readability's sake)</p>
<pre><code>@Value(&quot;${hosts.ratings}&quot;)
private String ratingsPath;

@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
    return builder.routes()
        .route(r -&gt; r.host(&quot;*&quot;).and().path(&quot;/api/ratings/**&quot;)
                .uri(ratingsPath + &quot;:2226/api/ratings/&quot;))
                ...other routes...
        .build();
}
</code></pre>
<p>This gets it values from the <code>application.properties</code> locally, and from an environment variable in docker, like so in the docker-compose:</p>
<pre><code>  apigw:
    build: ./Api-Gateway
    container_name: apigw
    links:
      - ratings
      ...
    depends_on:
      - ratings
      ...
    ports:
      - &quot;80:8080&quot;
    environment:
      - hosts_ratings=http://ratings
      ...
</code></pre>
<p>This configuration works just fine. However, when porting this to our kubernetes cluster, all routes get a <code>404</code>.
The deployment of our api gateway is as follows:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: apigw
  name: apigw-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: apigw
  template:
    metadata:
      labels:
        app: apigw
    spec:
      containers:
      - name: apigw
        image: redacted
        ports:
        - containerPort: 8080
        env:
        - name: hosts_ratings
          value: &quot;ratings-service.default.svc.cluster.local&quot;
        ...
</code></pre>
<p>With <code>ratings-service</code> being our ratings service (that definitely works, because when exposing it directly from its service, it does work), defined like this:</p>
<pre><code>apiVersion: v1
kind: Service
metadata: 
  name: ratings-service
  labels:
    app: ratings
spec:
  selector:
    app: ratings
  ports:
    - port: 2226
      targetPort: 2226
</code></pre>
<p>The service of our api gateway is as follows, using bare metal with an external IP that does work:</p>
<pre><code>apiVersion: v1
kind: Service
metadata: 
  name: apigw-service
  labels:
    app: apigw
spec:
  selector:
    app: apigw
  ports:
    - port: 80
      targetPort: 8080
  externalIPs:
    - A.B.C.D
</code></pre>
<p>How I believe it should work is that <code>ratings-service.default.svc.cluster.local</code> would get translated to the correct ip, filled in to the <code>ratingsPath</code> variable, and the query would succeed, but this is not the case.<br />
Our other services are able to communicate in the same way, but the api gateway does not seem to be able to do that.
What could be the problem?</p>

Raven
<p>Posting community wiki based on comment for better visibility. Feel free to expand it.</p>
<hr />
<p>The issue was a faulty version of the image:</p>
<blockquote>
<p>It seems like the service i was using just straight up didn't work. Must have been a faulty version of the image i was using.</p>
</blockquote>
<p>Check also:</p>
<ul>
<li><a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-services/" rel="nofollow noreferrer">Access Services Running on Clusters | Kubernetes</a></li>
<li><a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Service | Kubernetes</a></li>
<li><a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/" rel="nofollow noreferrer">Debug Services | Kubernetes</a></li>
<li><a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">DNS for Services and Pods | Kubernetes</a></li>
</ul>
