I wanna run a microservice which use DB. DB need to deploy in the same kubernetes cluster as well using PVC/PV. What is the kubernetes service name/command to use to implement such logic:
- Deploy the DB instance
- If 1 is successful, then deploy the microservice, else return to 1 and try (if 100 times fail - then stop and alarm)
- If 2 is successful, use work with it, autoscale if needed (autoscale kubernetes option)
I concern mostly about 1-2: the service cannot work without the DB, but at the same time need to be in different pods ( or am I wrong and it's better to put 2 containers: DB and service at the same pod?)
kubectl apply
with your yamls (with initContainer configured in your application). If you want to do that in more automative way you can think about using fluxCD/argoCD. – Jakubcontainers that run before the main container runs
and themain container
must be in the same pod? – J.J. Beam