-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-template.sh
More file actions
executable file
·33 lines (26 loc) · 997 Bytes
/
deploy-template.sh
File metadata and controls
executable file
·33 lines (26 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
set -euo pipefail
NS=""
BACKEND_IMAGE=""
FRONTEND_IMAGE=""
echo ">>>>>> Building Docker images"
docker build -t "$BACKEND_IMAGE" -f api/Dockerfile api
docker build -t "$FRONTEND_IMAGE" -f web/Dockerfile web
echo ">>>>>> Pushing images"
docker push "$BACKEND_IMAGE"
docker push "$FRONTEND_IMAGE"
# Check for existing Deployments
if kubectl get deployment -n "$NS" >/dev/null 2>&1; then
echo ">>>>>> Found existing deployments in ${NS}. Applying manifests…"
kubectl apply -f kubernetes -n "$NS"
echo ">>>>>> Rolling restart of all deployments:"
kubectl rollout restart deployment.apps/flask-deployment -n "$NS"
kubectl rollout restart deployment.apps/nextjs-deployment -n "$NS"
echo ">>>>>> Waiting for rollouts to finish…"
for deploy in $(kubectl get deployment -n "$NS" -o name); do
kubectl rollout status "$deploy" -n "$NS"
done
else
echo ">>>>>> Applying manifests…"
kubectl apply -f kubernetes -n "$NS"
fi
echo "✅ Deployment complete in namespace ${NS}."