<p>I have Consul running in my cluster and each node runs a consul-agent as a DaemonSet. I also have other DaemonSets that interact with Consul and therefore require a consul-agent to be running in order to communicate with the Consul servers.</p>

<p>My problem is, if my DaemonSet is started before the consul-agent, the application will error as it cannot connect to Consul and subsequently get restarted.</p>

<p>I also notice the same problem with other DaemonSets, e.g <a href="https://www.weave.works/oss/net/" rel="nofollow noreferrer">Weave</a>, as it requires kube-proxy and kube-dns. If Weave is started first, it will constantly restart until the kube services are ready.</p>

<p>I know I could add retry logic to my application, but I was wondering if it was possible to specify the order in which DaemonSets are scheduled?</p>

syscll
<p>Kubernetes itself does not provide a way to specific dependencies between pods / deployments / services (e.g. "start pod A only if service B is available" or "start pod A after pod B").</p>

<p>The currect approach (based on what I found while researching this) seems to be retry logic or an init container. To quote the <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#what-can-init-containers-be-used-for" rel="nofollow noreferrer">docs</a>:</p>

<blockquote>
  <p>They run to completion before any app Containers start, whereas app Containers run in parallel, so Init Containers provide an easy way to block or delay the startup of app Containers until some set of preconditions are met.</p>
</blockquote>

<p>This means you can either add retry logic to your application (which I would recommend as it might help you in different situations such as a short service outage) our you can use an init container that polls a health endpoint via the Kubernetes service name until it gets a satisfying response.</p>
