Automatically associate clients to pods

12/4/2018

Is it possible to have a client always connect to the same database in a cluster? I mean: I would like to have a pool of databases (all with the same image but data-wise independent between them). Then, I would like to expose an IP and port at the cluster. When a client connects to this address, I would like the Kubernetes to automatically associate this cliente with a brand new database inside the cluster. This database should never be associated to any other client. All the times the given client conencts to the IP and port at the cluster, it should connect to the same database.

In case a new client accesses the service and now fresh databases are available, I would like k8s to automatically create a new database and associate it to the client.

Is this possible or pure fantasy?

Thanks in advance!

--
cluster-computing
database
kubernetes
replication
testing

1 Answer

12/6/2018

I guess this is related to your other question on Exlusive client affinity . You could create databases that are exposed exclusively for particular clients. But you would need to write code to create them dynamically e.g. using the Kubernetes APIs. I can't see any Kubernetes feature to do the on-demand provisioning part. Kubernetes can automatically scale up a deployment in Kubernetes but that is quite different from automatically creating whole new deployments.

-- Ryan Dawson
Source: StackOverflow