<p>My microservice has multiple containers, each of which needs access to a different port. How do I expose this service on multiple ports using the Hasura CLI and project configuration files?</p>

<p>Edit: Adding the microservice's <code>k8s.yaml</code> (as requested by @iamnat)
Let's say I have two containers, <code>containerA</code> and <code>containerB</code>, that I want to expose over HTTP on ports <code>6379</code> and <code>8000</code> respectively.</p>

<pre><code>apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    creationTimestamp: null
    labels:
      app: www
      hasuraService: custom
    name: www
    namespace: '{{ cluster.metadata.namespaces.user }}'
  spec:
    replicas: 1
    strategy: {}
    template:
      metadata:
        creationTimestamp: null
        labels:
          app: www
      spec:
        containers:
        - name: containerA
          image: imageA
          ports:
          - containerPort: 6379
        - name: containerB
          image: imageB
          ports:
          - containerPort: 8000
        securityContext: {}
        terminationGracePeriodSeconds: 0
  status: {}
- apiVersion: v1
  kind: Service
  metadata:
    creationTimestamp: null
    labels:
      app: www
      hasuraService: custom
    name: www
    namespace: '{{ cluster.metadata.namespaces.user }}'
  spec:
    ports:
    - port: 6379
      name: containerA
      protocol: HTTP
      targetPort: 6379

    - port: 8000
      name: containerB
      protocol: HTTP
      targetPort: 8000

    selector:
      app: www
    type: ClusterIP
  status:
    loadBalancer: {}
kind: List
metadata: {}
</code></pre>

<p>TL;DR:
- Add an API gateway route for each HTTP endpoint you want to expose <a href="https://docs.hasura.io/0.15/manual/hasuractl/hasura_conf_generate-route.html" rel="nofollow noreferrer">[docs]</a></p>

<hr>

<p>Inside the kubernetes cluster, give your k8s spec this is what your setup will look like:</p>

<pre><code>http://www.default:8000  -&gt; containerA
http://www.default:6379  -&gt; containerB
</code></pre>

<p>So you need to create a route for each of those HTTP paths in <code>conf/routes.yaml</code>.</p>

<pre><code>www-a:
  /:
    upstreamService:
      name: www
      namespace: {{ cluster.metadata.namespaces.user }}
    upstreamServicePath: /
    upstreamServicePort: 8000
    corsPolicy: allow_all
www-b:
  /:
    upstreamService:
      name: www
      namespace: {{ cluster.metadata.namespaces.user }}
    upstreamServicePath: /
    upstreamServicePort: 6379
    corsPolicy: allow_all
</code></pre>

<p>This means that, you'll get the following:</p>

<pre><code>https://www-a.domain.com -&gt; containerA
https://www-a.domain.com -&gt; containerB
</code></pre>
