Dynamically mapping Ingress URL parameters

I’m quite new to Docker and even newer to Kubernetes, so sorry if this isn’t the right place to ask this. I’m trying to figure out what the correct tool is for what I’m trying to accomplish. Basic outline is this:

I have a Node-based server application with multiple users, and multiple what I’ll call “environments”, which consist of code extensions and modifications/additions to the database schema. Users can have access to multiple environments, but a web client will only connect to one at a time from a given browser tab. Each environment has the same core code, but connects to a different database and loads up its extensions at startup.

The URLs for the API are in the form /api/{environment-id}/endpoint . What I’d like to make happen is that when the first HTTP request comes in for a given {environment-id}, a new Docker instance is started, with that ID passed to it (presumably as an env var but it doesn’t have to be). Any subsequent requests with the same {environment-id} should go to the same instance without starting a new one. From what I’ve read of Ingress controllers, it sounds like this is exactly what they do, but all the examples that I’ve found involve using different Docker images based on the URL rather than passing part of the URL as a parameter, and they also have a finite number of static mappings. In my use case, environments can be created by users, so I won’t know when setting up configuration.

Is this something Kubernetes and Ingress are designed to do? Is there an existing tool to do something like this? Not asking anyone to hold my hand, but pointers to tutorials or other information would be much appreciated.

It’s sound like FaaS with custom runtime to me. You can dig into it to find out if it solves your problem:

And of course you can write your own controller which works as a default (catch-all) backend, creates Deployments and their Ingresses if they don’t exist.