diff --git a/deploy.sh b/deploy.sh index f954881..0f0df8e 100755 --- a/deploy.sh +++ b/deploy.sh @@ -25,9 +25,17 @@ apply_template() { apply_deployment() { - for file in $(find $1 -type f); do + deployment_name=$1 + deployment_files=$2 + + for file in $(find $2 -type f); do apply_template $file done + + kubectl wait --for=condition=available \ + --timeout=600s \ + deployment.apps/${deployment_name} \ + -n ${KUBE_NAMESPACE} } @@ -118,13 +126,13 @@ deploy_kubernetes() { configure_postgres - apply_deployment "./template/redis" + apply_deployment "redis-deployment" "./template/redis" - apply_deployment "./template/frontend" + apply_deployment "storage-deployment" "./template/storage" - apply_deployment "./template/storage" + apply_deployment "backend-deployment" "./template/backend" - apply_deployment "./template/backend" + apply_deployment "frontend-deployment" "./template/frontend" configure_ingress diff --git a/template/backend/backend.template.yaml b/template/backend/backend.template.yaml index eb3444a..d38c2ad 100644 --- a/template/backend/backend.template.yaml +++ b/template/backend/backend.template.yaml @@ -15,6 +15,18 @@ spec: spec: nodeSelector: ${WORKER_NODE_LABEL} + initContainers: + - name: wait-storage-init + image: busybox:latest + args: + - /bin/sh + - -c + - > + set -x; + while [ $(curl -sw '%{http_code}' "storage-service:8070/health" -o /dev/null) -ne 200 ]; do + sleep 15; + done + containers: - name: backend image: yoshiunfriendly/backend-hideyoshi.com @@ -32,7 +44,7 @@ spec: httpGet: path: /health port: 8070 - initialDelaySeconds: 120 + initialDelaySeconds: 60 livenessProbe: httpGet: path: /health diff --git a/template/frontend/frontend.template.yaml b/template/frontend/frontend.template.yaml index f092690..b71ccbd 100644 --- a/template/frontend/frontend.template.yaml +++ b/template/frontend/frontend.template.yaml @@ -17,6 +17,17 @@ spec: spec: nodeSelector: ${WORKER_NODE_LABEL} + initContainers: + - name: wait-backend-init + image: busybox:latest + args: + - /bin/sh + - -c + - > + set -x; + while [ $(curl -sw '%{http_code}' "backend-service:8000/health" -o /dev/null) -ne 200 ]; do + sleep 15; + done containers: - name: frontend image: yoshiunfriendly/frontend-hideyoshi.com:latest