Wait for another pod to be ready

Hi there,

I am searching for a nice and clean solution to replicate the depends_on statement from docker-compose in Kuberenetes running Rancher 2.
I know, that I have to do it via initContainers. Now I have e.g. a service that depends on a DB service. The DB service needs to be initialized (i.e. create table) the first time it is started and is ready once the table is there and database is ready to accept connections.
Now I could use a script for the depending service’s initContainer that always tries to connect to the DB and once it succeeds, checks for the table… But writing such a script for every depending service seems a bit off to me.
Because the DB pod already tells Kubernetes, that it’s ready using the exact same checks.
Now I found this How-To https://blog.giantswarm.io/wait-for-it-using-readiness-probes-for-service-dependencies-in-kubernetes/ that suggests using the K8s API to check for ready pods behind a service which would totally suit my needs.
Problem is now, that with Rancher in front of K8s, it’s fully RBAC enabled preventing the namespace’s default user from querying the API (forbidden).
Any idea how I could achieve this without creating a master user by hand everytime?

Would be super cool if anyone has a generic solution for this :slight_smile:
Thanks in advance