Kubernetes Deployments and Init Containers

前端 未结 2 1767
离开以前
离开以前 2021-02-13 05:46

I learned recently that Kubernetes has a feature called Init Containers. Awesome, because I can use this feature to wait for my postgres service and create/migrate the database

2条回答
  •  佛祖请我去吃肉
    2021-02-13 06:41

    You probably want to use readiness probes instead of init containers for this use case. Check out this link and a blog. Also note that a deployment will not send traffic to a pod that is not reported ready - If that was your worry.

    This is a well known pattern and a readiness probe in the web server would simply check the DB endpoint / data availability before reporting ready. This is a simple solution as opposed to the complexity of an extra init container and has the advantage of detecting DB outages correctly as well.

提交回复
热议问题