I am planning to create a special 'deployer' deployment on k8s (one 'deployer' per cluster). It's role would be to pull specifications from a central place, create k8s manifests and apply them. The end result should be multiple deployments, each in it's own namespace with service and ingress, as well as a secret containing DB credentials.
I don't want to directly transmit and manage the DB details. Instead, I was thinking of creating a CustomResourceDefinition 'dbservice' that would contain a DB service name among the rest. Then configure a k8s operator that would:
That way:
What needs to happen for this to work (according to my plan):
Since I'm fairly new to k8s and devops in general, I wanted to verify that this approach is sane and not an anti-pattern.
It's absolutely sane, and kind of it even implemented already https://github.com/mumoshu/aws-secret-operator but it uses AWS secret manager as a backend instead of DB
UPD: Another similar solution bubbled up just today: https://godaddy.github.io/2019/04/16/kubernetes-external-secrets/
Hashicorp Vault can do something similar for some DB providers - check out the documentation here. There is also the concept of service broker that can create cloud resources for you - see for example Azure Service Broker. Overall, this sounds pretty awesome, so if both of the solutions does not work for you - go ahead and build it!