<p>I am running a NodeJS image in my Kubernetes Pod, while exposing a specific port (9080), and running Traefik as a side-car container as reverse proxy. How do I specify Traefik route from the Deployment template.</p>

<p><strong>Deployment</strong></p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  labels:
    app: web
  name: web-controller
spec:
  replicas: 1
  selector:
     matchLabels:
       app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - image: "nodeJS-image"
        name: web
        ports:
        - containerPort: 9080
          name: http-server
      - image: "traefik-image"
        name: traefik-proxy
        ports:
        - containerPort: 80
          name: traefik-proxy
        - containerPort: 8080
          name: traefik-ui
        args:
        - --web
        - --kubernetes
</code></pre>

<p>If I understand correctly, you want to forward requests hitting the Traefik container to the Node.js application living in the same pod. Given that the application is configured statically from Traefik's perspective, you can simply mount a proper file provider configuration into the Traefik pod (presumably via a ConfigMap) pointing at the side car container.</p>

<p>The most simple way to achieve this (<a href="https://docs.traefik.io/configuration/backends/file/" rel="nofollow noreferrer">as documented</a>) is to append the following file provider configuration directly at the bottom of Traefik's TOML configuration file:</p>

<pre><code>[file]

[backends.backend.servers.server]
url = "http://127.0.0.1:9080"
[frontends.frontend]
backend = "backend"
[frontends.frontend.routes.route]
host = "machine-echo.example.com"
</code></pre>

<p>If you mount the TOML configuration file into the Traefik pod under a path other than the default one (<code>/etc/traefik.toml</code>), you will also need to pass the <code>--configFile</code> option in the manifest referencing the correct location of the file.</p>

<p>After that, any request hitting the Traefik container on port 80 with a host header of <code>machine-echo.example.com</code> should get forwarded to the Node.js side car container on port 9080.</p>
