<p>Apologies for a basic question. I have a simple Kubernetes deployment where I have 3 containers (each in their own pod) deployed to a Kubernetes cluster.</p>
<p>The <code>RESTapi</code> container is dependent upon the <code>OracleDB</code> container starting. However, the <code>OracleDB</code> container takes a while to startup and by that time the <code>RESTapi</code> container has restarted a number of times due to not being able to connect and ends up in a <code>Backoff</code> state.</p>
<p>Is there a more elegant solution for this?</p>
<p>I’ve also noticed that when the <code>RESTapi</code> container goes into the <code>Backoff</code> state it stops retrying?</p>

<p><em>This is a community wiki answer posted for better visibility. Feel free to expand it.</em></p>
<p>The best approach in this case is to improve your “RESTapi” application to provide a more reliable and fault-tolerant service that will allow it reconnect to the database anyway.</p>
<p>From <a href="https://github.com/learnk8s/kubernetes-production-best-practices/blob/dfebcd934ee6d6a6b8c4b8f7aa3cfad9a980f592/application-development.md#the-app-retries-connecting-to-dependent-services" rel="nofollow noreferrer">Kubernetes
production
best practices</a>:</p>
<blockquote>
<p>When the app starts, it shouldn't crash because a dependency such as a
database isn't ready.</p>
<p>Instead, the app should keep retrying to connect to the database until
it succeeds.</p>
<p>Kubernetes expects that application components can be started in any
order.</p>
</blockquote>
<p>In other case you can use solution with <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">Init Containers</a>.</p>
<p>You can look at this <a href="https://stackoverflow.com/questions/50838141/how-can-we-create-service-dependencies-using-kubernetes">question on stackoverflow</a>, which is just one of many others about the practical use of Init Containers for the case described.</p>
