Init container for Kubernetes to ensure a services are running before the other containers start.
10K+
This container's job is to stall a deployment from running any containers until some network conditions are met.
This image checks for and matches the conditions listed below (in order) before allowing the other containers in the deployment to run.
1 WAIT_FOR_IT
form: "true" or "false"
must equal "true" or the init container will be ignored
examples:
WAIT_FOR_IT="true"
WAIT_FOR_IT="false"
2 WAIT_FOR_PODS
Waits for other service's pods to be running before containers can start
form: <service-name>.<namespace>;<service-name-2>.<namespace-2>
examples:
WAIT_FOR_PODS="mysql.test"
WAIT_FOR_PODS="mysql.test;kube-dns.kube-system"
WAIT_FOR_EXTERNAL_IPSWaits for a k8s service to have an exposed external IP (not <pending> or ClusterIP)
form: <service-name>.<namespace>;<service-name-2>.<namespace-2>
examples:
WAIT_FOR_EXTERNAL_IPS="nginx.test"
WAIT_FOR_EXTERNAL_IPS="nginx.test;otherservice.default"
WAIT_FOR_DNS_MATCHESWaits for a domain name to match a specific IP before continuing
form: <domain-name>=<ip-address>;<domain-name-2>=<ip-address-2>
examples:
WAIT_FOR_DNS_MATCHES="drone.grinsides.com=35.237.17.14;grinsides.com=35.237.17.15"
If you need to make sure a database is running before starting a GUI pod, this is the init container for you.
To wait for:
mysql pod to start in databases namespacemongo pod to start in othernamespace namespaceredis pod to start in anothernamespace namespaceConfigure an init container in your deployment like this:
initContainers:
- name: "wait-for-services"
image: stevenaldinger/docker-k8s-wait-for-it
imagePullPolicy: Always
env:
- name: WAIT_FOR_IT
value: "true"
- name: WAIT_FOR_PODS
value: "mysql.databases;mongo.othernamespace;redis.anothernamespace"
- name: WAIT_FOR_EXTERNAL_IPS
value: "nginx.proxy"
- name: WAIT_FOR_DNS_MATCHES
value: "drone.grinsides.com=35.237.17.14;grinsides.com=35.237.17.15"
Run this to view init logs:
kubectl logs -f $(kubectl get po -l app=redis -o jsonpath='{.items[0].metadata.name}') -c redis-init
Run this to bash into init container:
kubectl exec -it $(kubectl get po -l app=redis -o jsonpath='{.items[0].metadata.name}') -c redis-init bash
Content type
Image
Digest
Size
4.4 MB
Last updated
about 8 years ago
docker pull stevenaldinger/docker-k8s-wait-for-it