A simple script that waits for Kubernetes services, jobs, or pods to reach a desired state to facilitate deployment and automation workflows.
A simple script that allows to wait for a k8s service, job or pods to enter a desired state
This tool is primarily used by Kubernetes administrators and DevOps engineers to automate and streamline deployment processes by waiting for specific Kubernetes resources to become ready or complete. It helps ensure that dependent services or jobs have reached their expected states before proceeding with further automation or deployment steps.
For Kubernetes versions 1.23 and below, use k8s-wait-for version 2.1 or higher, or versions 1.* to ensure compatibility. The tool is designed to be run inside the cluster using its container image, simplifying deployment without local installation. Pull requests and contributions are welcome, although the project is stable despite infrequent commits.
Run the tool directly on a Kubernetes cluster using kubectl with the provided container image:
kubectl run k8s-wait-for --rm -it --image ghcr.io/groundnuty/k8s-wait-for:v2.0 --restart Never --command /bin/sh
Use the built-in help command to explore usage options:
/ > wait_for.sh -h
wait_for.sh job [<job name> | -l<kubectl selector>]
Waits for all pods in the specified job to reach the 'Succeeded' state.
wait_for.sh pod [<pod name> | -l<kubectl selector>]
Waits for all pods matching the name or label selector to enter the 'Ready' state.
wait_for.sh service [<service name> | -l<kubectl selector>]
Waits for the specified Kubernetes service to become ready.
wait_for.sh pod -lapp=develop-volume-gluster-krakow
Waits for all pods with the label 'app=develop-volume-gluster-krakow' to enter the 'Ready' state.
wait_for.sh pod -l"release in (develop), chart notin (cross-support-job-3p)"
Waits for all pods matching a complex label selector to enter the 'Ready' state.
wait_for.sh pod-we -lapp=develop-volume-gluster-krakow
Waits for all pods with the label 'app=develop-volume-gluster-krakow' to enter either 'Ready' or 'Error' state.
wait_for.sh pod-wr -lapp=develop-volume-gluster-krakow
Waits for at least one pod with the label 'app=develop-volume-gluster-krakow' to enter the 'Ready' state, ignoring others in 'Error' state.
wait_for.sh job-we develop-volume-s3-krakow-init
Waits for all pods in the specified job to reach either 'Succeeded' or 'Failed' state.
wait_for.sh job-wr develop-volume-s3-krakow-init
Waits for at least one pod in the specified job to reach 'Succeeded' state, ignoring some 'Failed' pods.