title: Multiple FastAPI services on the same page
body: <p>I am using FastAPI to create multiple services.</p>
  <p>It works in a somewhat strange way, but basically I have a generic FastAPI service and a CI/CD that downloads multiple installable packages to create different services from it. It's all packaged neatly, I create multiple Docker images, then they are served by Kubernetes using deployments, services (separate pods, one container per pod) and ingress.</p>
  <p>Now, I've configured ingress to serve those services from the same host. The only thing that is different for those services is the app root path. So for example I have:</p>
  <ul>
  <li><code>foo.example.com/foo</code> - 1st service</li>
  <li><code>foo.example.com/bar</code> - 2nd service</li>
  </ul>
  <p>If I go to <code>foo.example.com/foo/docs</code>, I am greeted with Swagger documentation and I can select the app root path at the top of the page. Unfortunately, there's only one option: <code>/foo</code>. Same for the second service, but this time it's <code>/bar</code>.</p>
  <p>Now I know that those services run in separate containers in separate pods in my k8s cluster, but I was wondering if there's a way to for example go to <code>foo.example.com</code> or to a particular service like <code>foo.example.com/foo</code> and have all the services listed in Swagger's drop-down menu, so I can select any of them and be redirected to it. It would be huge improvement from a user experience point of view.</p>
  <p>@Edit, Ingress manifest file:</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: my-ingress
    annotations:
      kubernetes.io/ingress.class: &quot;nginx&quot;
      nginx.ingress.kubernetes.io/rewrite-target: /$1
      external-dns/manage-entries: &quot;true&quot;
  spec:
    rules:
    - http:
        paths:
        - path: /foo/(.*)
          pathType: Prefix
          backend:
            service:
              name: foo-service
              port:
                number: 80
      host: test.example.com
    - http:
        paths:
        - path: /bar/(.*)
          pathType: Prefix
          backend:
            service:
              name: bar-service
              port:
                number: 80
      host: test.example.com
    - http:
        paths:
        - path: /baz/(.*)
          pathType: Prefix
          backend:
            service:
              name: baz-service
              port:
                number: 80
      host: test.example.com
  </code></pre>