initContainers:
- name: init-myservice
image: busybox:1.28
command: ['sh', '-c', "until nslookup myservice; do echo waiting for myservice; sleep 2; done"]
I am using nslookup to wait until another service comes up. However, that does not solve my problem. As service will comes up but the corresponding app - pod maybe not ready. In this case, service dependency wont be handle.
How to ensure that one app1 is running before start app2?
I had similar problems with docker-compose in the past. There are two approaches I used to resolve them. Both of them assume that services will expose a port to listen to.
command
will be something like: initContainers: - name: init-myservice image: busybox:1.28 command: ['sh', '-c', "until timeout 2 bash -c \"</dev/tcp/myservice/${MY_SERVICE_TCP_PORT}\"; do echo waiting for myservice; sleep 2; done"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.