From e1aadd188532cb9e4451f1d1086e0eab7a1628a8 Mon Sep 17 00:00:00 2001 From: Hy3n4 Date: Tue, 24 Sep 2024 10:48:53 +0200 Subject: [PATCH] feat(make): make wait for services better when deploying dev infratructure Signed-off-by: Hy3n4 --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4cb446a..acf2631 100644 --- a/Makefile +++ b/Makefile @@ -170,7 +170,15 @@ $(ENVTEST): $(LOCALBIN) deploydev: @$(KUBECTL) apply -R -f devel/ @echo "Waiting for services to come online for the port-forwards..." - @sleep 5 + @until [ "$$($(KUBECTL) get pods -l app=grafana -o jsonpath='{.items}')}" != "[]" ] && \ + [ "$$($(KUBECTL) get pods -l app=grafana -o jsonpath='{.items[0].status.containerStatuses[0].ready}')" == "true" ]; do \ + echo "Waiting for Grafana to be ready..." && sleep 2; \ + done + @until [ "$$($(KUBECTL) get pods -l app=mimir -o jsonpath='{.items}')}" != "[]" ] && \ + [ "$$($(KUBECTL) get pods -l app=mimir -o jsonpath='{.items[0].status.containerStatuses[0].ready}')" == "true" ]; do \ + echo "Waiting for Mimir to be ready..." && sleep 2; \ + done + @echo "Services are ready. Setting up port-forwards..." @$(KUBECTL) port-forward svc/grafana 3000:3000 > /dev/null 2>&1 & @$(KUBECTL) port-forward svc/mimir-service 9009:9009 >/dev/null 2>&1 & @echo "Port-forwards activated. Reach Grafana on port 3000 and Mimir on port 9009."