<p>We had configured a kubernetes cluster where we deploy various services using spring boot and we have one service that is Spring Cloud Config Server.</p>

<p>Our trouble is that when we start the cluster all the services try to connect to the config server to download the configuration, and since the Config Server has not yet started all the services fail, causing kubernetes to retry the initialization and consuming many resources so that config server it self can not start.</p>

<p>We are wondering if there is a way to initialize all services in such a way that do not over load the cluster or so that they pacefully wait until the config server starts. As of now, all services start and we have to wait for like 20 minutes until the cluster works its way out.</p>

<p>Thanks in advance</p>

<p>You can use <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">Init Containers</a> to ping for the server until it is online. An example would be:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: web
  replicas: 1
  template:
    metadata:
      labels:
        app: web
    spec:
      initContainers:
      - name: wait-config-server
        image: busybox
        command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 config-server 8080 &amp;&amp; exit 0 || sleep 3; done; exit 1"]
      containers:
      - name: web
        image: my-mage
        ports:
        - containerPort: 80
          ...
</code></pre>

<p>In this example I am using an <a href="https://www.commandlinux.com/man-page/man1/nc.1.html" rel="nofollow noreferrer">nc</a> command for pinging the server but you can also use wget, curl or whatever is suited best for you.</p>
