因此,您需要在部署后的第一个可用pod上运行一些db脚本。
如果在展开创建过程中遵循以下步骤,它是否适用:
$ kubectl apply -f app-deployment.yml
// This will give some time for the pod to start.
$ WAIT_BEFORE_DATABASE_SETUP="${WAIT_BEFORE_DATABASE_SETUP-120}"
$ sleep $WAIT_BEFORE_DATABASE_SETUP
// Pick any one pod which is in Running State
$ APP_POD_NAME=$(kubectl get pods --field-selector=status.phase=Running -o=custom-columns=NAME:.metadata.name | grep <deployment-name> | head -1)
$ kubectl exec -it $APP_POD_NAME -- bash -c "/scripts/run_db_updates.sh"