Kubernetes - wait for other pod to be ready

后端 未结 4 1048
难免孤独
难免孤独 2020-12-03 03:07

I have two applications - app1 and app2, where app1 is a config server that holds configs for app2

4条回答
  •  猫巷女王i
    2020-12-03 03:24

    You need to use initContainers. Following is an example of how you can do in your YAML file

    initContainers:
    - name: wait-for-other-pod
      image: docker.some.image
      args:
      - /bin/sh
      - -c
      - >
        set -x;
        while [ $(curl -sw '%{http_code}' "http://www..com" -o /dev/null) -ne 200 ]; do
          sleep 15;
        done
    

    I have used curl to hit the health check endpoint, you can use any other UNIX command to check if the other pod is ready.

提交回复
热议问题