I have an application which processes a single stream of data. Each stream has a unique identifier and a URL. The number of streams is dynamic, but I only want one instance of the application to process each stream.
I want to build the infrastructure to have a single application to process each stream, and expand dynamically when new streams are added. (You can assume that the list of streams is in a database) If the processor of the stream dies, it needs to be restarted automatically.
I was exploring using Kubernetes StatefulSets for this, since each instance will have its unique identifier, but I don't know how to link these to a unique stream, and how to trigger new instances to be executed when new streams are added (as automatically as possible). Maybe using different namespaces, but I want to be able to do it dynamically.
I am a bit new to Kubernetes, so not too sure if I am missing something obvious. Is there a way to achieve this? Similar to how for example databases have master and slaves with different configurations, but more dynamic since streams can be added or deleted during execution.
How is it best to go about something like this?