Photo by Aron Visuals / Unsplash

TIL - Add wait between Kubernetes deployments

Today I Learned Oct 2, 2022

When building Kubernetes deployment scripts for local testing, we often encounter scenarios where we have to wait for a database instance before deploying an application.

In order to add a wait between deployments, we can add a rollout status command like this -

# deploy a database using a deployment manifest file
kubectl apply -f database-deployment.yaml

# wait for the rollout before running the application
kubectl rollout status deployment/database-deployment

# deploy application using a deployment manifest file
kubectl apply -f application-deployment.yaml

The output will be something like this -

Waiting for rollout to finish: 1 out of 1 new replicas have been updated...
deployment "database-deployment" successfully rolled out
deployment "application-deployment" successfully rolled out