两个 pod已成功创建,app
并且postgres
能够通过节点中彼此的服务进行通信。在当前流程中,两个 pod 是同时创建的,但可以更改为按顺序创建/启动它们。
最初,postgres
pod 中的数据库容器是空的,需要播种。种子进程通过app
pod,因此它也需要启动并运行。一旦postgres
播种,app
仍然不知道这个新数据,需要重新启动。这本身就是一个缺陷app
,我无法控制。
目前,流程是:
kubectl create -f pods.yaml # creates `app` and `postgres` pods
kubectl exec app -- bash -c "<seed command>"
kubectl delete pod app
sleep 45 # takes a while for `app` to terminate
kubectl create -f pods.yaml # Ignore the "postgres pod and service already exist" error
有没有更好的方法来自动协调app
一旦postgres
达到种子状态的重启?
也许我完全缺少 Kubernetes 的某些方面/功能集,这有助于解决这种情况......